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	_LIBDEVINFO_H
28*7c478bd9Sstevel@tonic-gate #define	_LIBDEVINFO_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include <errno.h>
33*7c478bd9Sstevel@tonic-gate #include <sys/param.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
35*7c478bd9Sstevel@tonic-gate #include <sys/sunmdi.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/openpromio.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
38*7c478bd9Sstevel@tonic-gate #include <sys/devinfo_impl.h>
39*7c478bd9Sstevel@tonic-gate #include <limits.h>
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
42*7c478bd9Sstevel@tonic-gate extern "C" {
43*7c478bd9Sstevel@tonic-gate #endif
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate /*
46*7c478bd9Sstevel@tonic-gate  * flags for di_walk_node
47*7c478bd9Sstevel@tonic-gate  */
48*7c478bd9Sstevel@tonic-gate #define	DI_WALK_CLDFIRST	0
49*7c478bd9Sstevel@tonic-gate #define	DI_WALK_SIBFIRST	1
50*7c478bd9Sstevel@tonic-gate #define	DI_WALK_LINKGEN		2
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate #define	DI_WALK_MASK		0xf
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate /*
55*7c478bd9Sstevel@tonic-gate  * flags for di_walk_link
56*7c478bd9Sstevel@tonic-gate  */
57*7c478bd9Sstevel@tonic-gate #define	DI_LINK_SRC		1
58*7c478bd9Sstevel@tonic-gate #define	DI_LINK_TGT		2
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate /*
61*7c478bd9Sstevel@tonic-gate  * return code for node_callback
62*7c478bd9Sstevel@tonic-gate  */
63*7c478bd9Sstevel@tonic-gate #define	DI_WALK_CONTINUE	0
64*7c478bd9Sstevel@tonic-gate #define	DI_WALK_PRUNESIB	-1
65*7c478bd9Sstevel@tonic-gate #define	DI_WALK_PRUNECHILD	-2
66*7c478bd9Sstevel@tonic-gate #define	DI_WALK_TERMINATE	-3
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate /*
69*7c478bd9Sstevel@tonic-gate  * flags for di_walk_minor
70*7c478bd9Sstevel@tonic-gate  */
71*7c478bd9Sstevel@tonic-gate #define	DI_CHECK_ALIAS		0x10
72*7c478bd9Sstevel@tonic-gate #define	DI_CHECK_INTERNAL_PATH	0x20
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate #define	DI_CHECK_MASK		0xf0
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate /* nodeid types */
77*7c478bd9Sstevel@tonic-gate #define	DI_PSEUDO_NODEID	-1
78*7c478bd9Sstevel@tonic-gate #define	DI_SID_NODEID		-2
79*7c478bd9Sstevel@tonic-gate #define	DI_PROM_NODEID		-3
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate /* node & device states */
82*7c478bd9Sstevel@tonic-gate #define	DI_DRIVER_DETACHED	0x8000
83*7c478bd9Sstevel@tonic-gate #define	DI_DEVICE_OFFLINE	0x1
84*7c478bd9Sstevel@tonic-gate #define	DI_DEVICE_DOWN		0x2
85*7c478bd9Sstevel@tonic-gate #define	DI_BUS_QUIESCED		0x100
86*7c478bd9Sstevel@tonic-gate #define	DI_BUS_DOWN		0x200
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate /* property types */
89*7c478bd9Sstevel@tonic-gate #define	DI_PROP_TYPE_BOOLEAN	0
90*7c478bd9Sstevel@tonic-gate #define	DI_PROP_TYPE_INT	1
91*7c478bd9Sstevel@tonic-gate #define	DI_PROP_TYPE_STRING	2
92*7c478bd9Sstevel@tonic-gate #define	DI_PROP_TYPE_BYTE	3
93*7c478bd9Sstevel@tonic-gate #define	DI_PROP_TYPE_UNKNOWN	4
94*7c478bd9Sstevel@tonic-gate #define	DI_PROP_TYPE_UNDEF_IT	5
95*7c478bd9Sstevel@tonic-gate #define	DI_PROP_TYPE_INT64	6
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate /* private macro for checking if a prop type is valid */
98*7c478bd9Sstevel@tonic-gate #define	DI_PROP_TYPE_VALID(type) \
99*7c478bd9Sstevel@tonic-gate 	((((type) >= DI_PROP_TYPE_INT) && ((type) <= DI_PROP_TYPE_BYTE)) || \
100*7c478bd9Sstevel@tonic-gate 	    ((type) == DI_PROP_TYPE_INT64))
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate /* opaque handles */
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate typedef struct di_node *di_node_t;	/* opaque handle to node */
105*7c478bd9Sstevel@tonic-gate typedef struct di_minor *di_minor_t;	/* opaque handle to minor node */
106*7c478bd9Sstevel@tonic-gate typedef struct di_prop *di_prop_t;	/* opaque handle to property */
107*7c478bd9Sstevel@tonic-gate typedef struct di_prom_prop *di_prom_prop_t;	/* opaque handle to prom prop */
108*7c478bd9Sstevel@tonic-gate typedef struct di_prom_handle *di_prom_handle_t;	/* opaque handle */
109*7c478bd9Sstevel@tonic-gate typedef struct di_path *di_path_t;	/* opaque handle */
110*7c478bd9Sstevel@tonic-gate typedef struct di_path_prop *di_path_prop_t;	/* opaque handle */
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate typedef struct di_devlink_handle *di_devlink_handle_t;	/* devlink snapshot */
113*7c478bd9Sstevel@tonic-gate typedef struct di_devlink *di_devlink_t;	/* opaque handle to devlink */
114*7c478bd9Sstevel@tonic-gate typedef struct di_link *di_link_t;	/* opaque handle to link */
115*7c478bd9Sstevel@tonic-gate typedef struct di_lnode *di_lnode_t; /* opaque handle to endpoint */
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate /*
118*7c478bd9Sstevel@tonic-gate  * Null handles to make handles really opaque
119*7c478bd9Sstevel@tonic-gate  */
120*7c478bd9Sstevel@tonic-gate #define	DI_NODE_NIL	NULL
121*7c478bd9Sstevel@tonic-gate #define	DI_LINK_NIL	NULL
122*7c478bd9Sstevel@tonic-gate #define	DI_LNODE_NIL	NULL
123*7c478bd9Sstevel@tonic-gate #define	DI_MINOR_NIL	NULL
124*7c478bd9Sstevel@tonic-gate #define	DI_PROP_NIL	NULL
125*7c478bd9Sstevel@tonic-gate #define	DI_PROM_PROP_NIL	NULL
126*7c478bd9Sstevel@tonic-gate #define	DI_PROM_HANDLE_NIL	NULL
127*7c478bd9Sstevel@tonic-gate #define	DI_PATH_NIL	NULL
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate /* Interface Prototypes */
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate /*
132*7c478bd9Sstevel@tonic-gate  * Snapshot initialization and cleanup
133*7c478bd9Sstevel@tonic-gate  */
134*7c478bd9Sstevel@tonic-gate extern di_node_t di_init(const char *phys_path, uint_t flag);
135*7c478bd9Sstevel@tonic-gate extern void di_fini(di_node_t root);
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate /*
138*7c478bd9Sstevel@tonic-gate  * tree traversal
139*7c478bd9Sstevel@tonic-gate  */
140*7c478bd9Sstevel@tonic-gate extern di_node_t di_parent_node(di_node_t node);
141*7c478bd9Sstevel@tonic-gate extern di_node_t di_sibling_node(di_node_t node);
142*7c478bd9Sstevel@tonic-gate extern di_node_t di_child_node(di_node_t node);
143*7c478bd9Sstevel@tonic-gate extern di_node_t di_drv_first_node(const char *drv_name, di_node_t root);
144*7c478bd9Sstevel@tonic-gate extern di_node_t di_drv_next_node(di_node_t node);
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate /*
147*7c478bd9Sstevel@tonic-gate  * tree walking assistants
148*7c478bd9Sstevel@tonic-gate  */
149*7c478bd9Sstevel@tonic-gate extern int di_walk_node(di_node_t root, uint_t flag, void *arg,
150*7c478bd9Sstevel@tonic-gate     int (*node_callback)(di_node_t node, void *arg));
151*7c478bd9Sstevel@tonic-gate extern int di_walk_minor(di_node_t root, const char *minortype, uint_t flag,
152*7c478bd9Sstevel@tonic-gate     void *arg, int (*minor_callback)(di_node_t node, di_minor_t minor,
153*7c478bd9Sstevel@tonic-gate     void *arg));
154*7c478bd9Sstevel@tonic-gate extern int di_walk_link(di_node_t root, uint_t flag, uint_t endpoint,
155*7c478bd9Sstevel@tonic-gate     void *arg, int (*link_callback)(di_link_t link, void *arg));
156*7c478bd9Sstevel@tonic-gate extern int di_walk_lnode(di_node_t root, uint_t flag,
157*7c478bd9Sstevel@tonic-gate     void *arg, int (*lnode_callback)(di_lnode_t lnode, void *arg));
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate extern void di_node_private_set(di_node_t node, void *data);
160*7c478bd9Sstevel@tonic-gate extern void *di_node_private_get(di_node_t node);
161*7c478bd9Sstevel@tonic-gate extern void di_minor_private_set(di_minor_t minor, void *data);
162*7c478bd9Sstevel@tonic-gate extern void *di_minor_private_get(di_minor_t minor);
163*7c478bd9Sstevel@tonic-gate extern void di_lnode_private_set(di_lnode_t lnode, void *data);
164*7c478bd9Sstevel@tonic-gate extern void *di_lnode_private_get(di_lnode_t lnode);
165*7c478bd9Sstevel@tonic-gate extern void di_link_private_set(di_link_t link, void *data);
166*7c478bd9Sstevel@tonic-gate extern void *di_link_private_get(di_link_t link);
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate /*
169*7c478bd9Sstevel@tonic-gate  * generic node parameters
170*7c478bd9Sstevel@tonic-gate  */
171*7c478bd9Sstevel@tonic-gate extern char *di_node_name(di_node_t node);
172*7c478bd9Sstevel@tonic-gate extern char *di_bus_addr(di_node_t node);
173*7c478bd9Sstevel@tonic-gate extern char *di_binding_name(di_node_t node);
174*7c478bd9Sstevel@tonic-gate extern int di_compatible_names(di_node_t, char **names);
175*7c478bd9Sstevel@tonic-gate extern int di_instance(di_node_t node);
176*7c478bd9Sstevel@tonic-gate extern int di_nodeid(di_node_t node);
177*7c478bd9Sstevel@tonic-gate extern int di_driver_major(di_node_t node);
178*7c478bd9Sstevel@tonic-gate extern uint_t di_state(di_node_t node);
179*7c478bd9Sstevel@tonic-gate extern ddi_node_state_t di_node_state(di_node_t node);
180*7c478bd9Sstevel@tonic-gate extern ddi_devid_t di_devid(di_node_t node);
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate extern char *di_driver_name(di_node_t node);
183*7c478bd9Sstevel@tonic-gate extern uint_t di_driver_ops(di_node_t node);
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate extern char *di_devfs_path(di_node_t node);
186*7c478bd9Sstevel@tonic-gate extern char *di_devfs_minor_path(di_minor_t minor);
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate extern void di_devfs_path_free(char *path_buf);
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate /*
191*7c478bd9Sstevel@tonic-gate  * layering data access
192*7c478bd9Sstevel@tonic-gate  */
193*7c478bd9Sstevel@tonic-gate extern di_link_t	di_link_next_by_node(di_node_t node,
194*7c478bd9Sstevel@tonic-gate     di_link_t link, uint_t endpoint);
195*7c478bd9Sstevel@tonic-gate extern di_link_t	di_link_next_by_lnode(di_lnode_t lnode,
196*7c478bd9Sstevel@tonic-gate     di_link_t link, uint_t endpoint);
197*7c478bd9Sstevel@tonic-gate extern di_lnode_t	di_link_to_lnode(di_link_t link, uint_t endpoint);
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate extern di_lnode_t	di_lnode_next(di_node_t node, di_lnode_t lnode);
200*7c478bd9Sstevel@tonic-gate extern char		*di_lnode_name(di_lnode_t lnode);
201*7c478bd9Sstevel@tonic-gate extern di_node_t	di_lnode_devinfo(di_lnode_t lnode);
202*7c478bd9Sstevel@tonic-gate extern int		di_lnode_devt(di_lnode_t lnode, dev_t *devt);
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate extern int		di_link_spectype(di_link_t link);
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate /*
207*7c478bd9Sstevel@tonic-gate  * minor data access
208*7c478bd9Sstevel@tonic-gate  */
209*7c478bd9Sstevel@tonic-gate extern di_minor_t	di_minor_next(di_node_t node, di_minor_t minor);
210*7c478bd9Sstevel@tonic-gate extern di_node_t	di_minor_devinfo(di_minor_t minor);
211*7c478bd9Sstevel@tonic-gate extern ddi_minor_type	di_minor_type(di_minor_t minor);
212*7c478bd9Sstevel@tonic-gate extern char		*di_minor_name(di_minor_t minor);
213*7c478bd9Sstevel@tonic-gate extern dev_t		di_minor_devt(di_minor_t minor);
214*7c478bd9Sstevel@tonic-gate extern int		di_minor_spectype(di_minor_t minor);
215*7c478bd9Sstevel@tonic-gate extern char		*di_minor_nodetype(di_minor_t node);
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate /*
218*7c478bd9Sstevel@tonic-gate  * Software property access
219*7c478bd9Sstevel@tonic-gate  */
220*7c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_next(di_node_t node, di_prop_t prop);
221*7c478bd9Sstevel@tonic-gate extern dev_t di_prop_devt(di_prop_t prop);
222*7c478bd9Sstevel@tonic-gate extern char *di_prop_name(di_prop_t prop);
223*7c478bd9Sstevel@tonic-gate extern int di_prop_type(di_prop_t prop);
224*7c478bd9Sstevel@tonic-gate extern int di_prop_ints(di_prop_t prop, int **prop_data);
225*7c478bd9Sstevel@tonic-gate extern int di_prop_int64(di_prop_t prop, int64_t **prop_data);
226*7c478bd9Sstevel@tonic-gate extern int di_prop_strings(di_prop_t prop, char **prop_data);
227*7c478bd9Sstevel@tonic-gate extern int di_prop_bytes(di_prop_t prop, uchar_t **prop_data);
228*7c478bd9Sstevel@tonic-gate extern int di_prop_lookup_ints(dev_t dev, di_node_t node,
229*7c478bd9Sstevel@tonic-gate     const char *prop_name, int **prop_data);
230*7c478bd9Sstevel@tonic-gate extern int di_prop_lookup_int64(dev_t dev, di_node_t node,
231*7c478bd9Sstevel@tonic-gate     const char *prop_name, int64_t **prop_data);
232*7c478bd9Sstevel@tonic-gate extern int di_prop_lookup_strings(dev_t dev, di_node_t node,
233*7c478bd9Sstevel@tonic-gate     const char *prop_name, char **prop_data);
234*7c478bd9Sstevel@tonic-gate extern int di_prop_lookup_bytes(dev_t dev, di_node_t node,
235*7c478bd9Sstevel@tonic-gate     const char *prop_name, uchar_t **prop_data);
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate /*
238*7c478bd9Sstevel@tonic-gate  * PROM property access
239*7c478bd9Sstevel@tonic-gate  */
240*7c478bd9Sstevel@tonic-gate extern di_prom_handle_t di_prom_init(void);
241*7c478bd9Sstevel@tonic-gate extern void di_prom_fini(di_prom_handle_t ph);
242*7c478bd9Sstevel@tonic-gate 
243*7c478bd9Sstevel@tonic-gate extern di_prom_prop_t di_prom_prop_next(di_prom_handle_t ph, di_node_t node,
244*7c478bd9Sstevel@tonic-gate     di_prom_prop_t prom_prop);
245*7c478bd9Sstevel@tonic-gate 
246*7c478bd9Sstevel@tonic-gate extern char *di_prom_prop_name(di_prom_prop_t prom_prop);
247*7c478bd9Sstevel@tonic-gate extern int di_prom_prop_data(di_prom_prop_t prop, uchar_t **prom_prop_data);
248*7c478bd9Sstevel@tonic-gate 
249*7c478bd9Sstevel@tonic-gate extern int di_prom_prop_lookup_ints(di_prom_handle_t prom, di_node_t node,
250*7c478bd9Sstevel@tonic-gate     const char *prom_prop_name, int **prom_prop_data);
251*7c478bd9Sstevel@tonic-gate extern int di_prom_prop_lookup_strings(di_prom_handle_t prom, di_node_t node,
252*7c478bd9Sstevel@tonic-gate     const char *prom_prop_name, char **prom_prop_data);
253*7c478bd9Sstevel@tonic-gate extern int di_prom_prop_lookup_bytes(di_prom_handle_t prom, di_node_t node,
254*7c478bd9Sstevel@tonic-gate     const char *prom_prop_name, uchar_t **prom_prop_data);
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate /*
257*7c478bd9Sstevel@tonic-gate  * Private interfaces
258*7c478bd9Sstevel@tonic-gate  *
259*7c478bd9Sstevel@tonic-gate  * The interfaces and structures below are private to this implementation
260*7c478bd9Sstevel@tonic-gate  * of Solaris and are subject to change at any time without notice.
261*7c478bd9Sstevel@tonic-gate  *
262*7c478bd9Sstevel@tonic-gate  * Applications and drivers using these interfaces will fail
263*7c478bd9Sstevel@tonic-gate  * to run on future releases.
264*7c478bd9Sstevel@tonic-gate  */
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate /*
267*7c478bd9Sstevel@tonic-gate  * Interfaces for accessing I/O multipathing data
268*7c478bd9Sstevel@tonic-gate  */
269*7c478bd9Sstevel@tonic-gate /* XXX remove di_path_next() after updating NWS consolidation */
270*7c478bd9Sstevel@tonic-gate extern di_path_t di_path_next(di_node_t node, di_path_t path);
271*7c478bd9Sstevel@tonic-gate extern di_path_t di_path_next_phci(di_node_t node, di_path_t path);
272*7c478bd9Sstevel@tonic-gate extern di_path_t di_path_next_client(di_node_t node, di_path_t path);
273*7c478bd9Sstevel@tonic-gate extern di_path_state_t di_path_state(di_path_t path);
274*7c478bd9Sstevel@tonic-gate extern char *di_path_addr(di_path_t path, char *buf);
275*7c478bd9Sstevel@tonic-gate extern di_node_t di_path_client_node(di_path_t path);
276*7c478bd9Sstevel@tonic-gate extern void di_path_client_path(di_path_t path, char *buf);
277*7c478bd9Sstevel@tonic-gate extern di_node_t di_path_phci_node(di_path_t path);
278*7c478bd9Sstevel@tonic-gate extern void di_path_phci_path(di_path_t path, char *buf);
279*7c478bd9Sstevel@tonic-gate extern di_path_prop_t di_path_prop_next(di_path_t path, di_path_prop_t prop);
280*7c478bd9Sstevel@tonic-gate extern char *di_path_prop_name(di_path_prop_t prop);
281*7c478bd9Sstevel@tonic-gate extern int di_path_prop_type(di_path_prop_t prop);
282*7c478bd9Sstevel@tonic-gate extern int di_path_prop_len(di_path_prop_t prop);
283*7c478bd9Sstevel@tonic-gate extern int di_path_prop_bytes(di_path_prop_t prop, uchar_t **prop_data);
284*7c478bd9Sstevel@tonic-gate extern int di_path_prop_ints(di_path_prop_t prop, int **prop_data);
285*7c478bd9Sstevel@tonic-gate extern int di_path_prop_int64s(di_path_prop_t prop, int64_t **prop_data);
286*7c478bd9Sstevel@tonic-gate extern int di_path_prop_strings(di_path_prop_t prop, char **prop_data);
287*7c478bd9Sstevel@tonic-gate extern int di_path_prop_lookup_bytes(di_path_t path, const char *prop_name,
288*7c478bd9Sstevel@tonic-gate     uchar_t **prop_data);
289*7c478bd9Sstevel@tonic-gate extern int di_path_prop_lookup_ints(di_path_t path, const char *prop_name,
290*7c478bd9Sstevel@tonic-gate     int **prop_data);
291*7c478bd9Sstevel@tonic-gate extern int di_path_prop_lookup_int64s(di_path_t path, const char *prop_name,
292*7c478bd9Sstevel@tonic-gate     int64_t **prop_data);
293*7c478bd9Sstevel@tonic-gate extern int di_path_prop_lookup_strings(di_path_t path, const char *prop_name,
294*7c478bd9Sstevel@tonic-gate     char **prop_data);
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate 
297*7c478bd9Sstevel@tonic-gate /*
298*7c478bd9Sstevel@tonic-gate  * Interfaces for private data
299*7c478bd9Sstevel@tonic-gate  */
300*7c478bd9Sstevel@tonic-gate extern di_node_t di_init_driver(const char *drv_name, uint_t flag);
301*7c478bd9Sstevel@tonic-gate extern di_node_t di_init_impl(const char *phys_path, uint_t flag,
302*7c478bd9Sstevel@tonic-gate     struct di_priv_data *priv_data);
303*7c478bd9Sstevel@tonic-gate 
304*7c478bd9Sstevel@tonic-gate /*
305*7c478bd9Sstevel@tonic-gate  * Prtconf needs to know property lists, raw prop_data, and private data
306*7c478bd9Sstevel@tonic-gate  */
307*7c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_drv_next(di_node_t node, di_prop_t prop);
308*7c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_sys_next(di_node_t node, di_prop_t prop);
309*7c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_global_next(di_node_t node, di_prop_t prop);
310*7c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_hw_next(di_node_t node, di_prop_t prop);
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate extern int di_prop_rawdata(di_prop_t prop, uchar_t **prop_data);
313*7c478bd9Sstevel@tonic-gate extern void *di_parent_private_data(di_node_t node);
314*7c478bd9Sstevel@tonic-gate extern void *di_driver_private_data(di_node_t node);
315*7c478bd9Sstevel@tonic-gate 
316*7c478bd9Sstevel@tonic-gate /*
317*7c478bd9Sstevel@tonic-gate  * Types of links for devlink lookup
318*7c478bd9Sstevel@tonic-gate  */
319*7c478bd9Sstevel@tonic-gate #define	DI_PRIMARY_LINK		0x01
320*7c478bd9Sstevel@tonic-gate #define	DI_SECONDARY_LINK	0x02
321*7c478bd9Sstevel@tonic-gate #define	DI_LINK_TYPES		0x03
322*7c478bd9Sstevel@tonic-gate 
323*7c478bd9Sstevel@tonic-gate /*
324*7c478bd9Sstevel@tonic-gate  * Flag for di_devlink_init()
325*7c478bd9Sstevel@tonic-gate  */
326*7c478bd9Sstevel@tonic-gate #define	DI_MAKE_LINK	0x01
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate /*
329*7c478bd9Sstevel@tonic-gate  * Flag for di_devlink_close()
330*7c478bd9Sstevel@tonic-gate  */
331*7c478bd9Sstevel@tonic-gate #define	DI_LINK_ERROR	0x01
332*7c478bd9Sstevel@tonic-gate 
333*7c478bd9Sstevel@tonic-gate /*
334*7c478bd9Sstevel@tonic-gate  * For devfsadm synchronous link creation interfaces
335*7c478bd9Sstevel@tonic-gate  */
336*7c478bd9Sstevel@tonic-gate #define	DEVFSADM_SYNCH_DOOR	".devfsadm_synch_door"
337*7c478bd9Sstevel@tonic-gate 
338*7c478bd9Sstevel@tonic-gate /*
339*7c478bd9Sstevel@tonic-gate  * devlink create argument
340*7c478bd9Sstevel@tonic-gate  */
341*7c478bd9Sstevel@tonic-gate struct dca_off {
342*7c478bd9Sstevel@tonic-gate 	uint32_t	dca_root;
343*7c478bd9Sstevel@tonic-gate 	uint32_t	dca_minor;
344*7c478bd9Sstevel@tonic-gate 	uint32_t	dca_driver;
345*7c478bd9Sstevel@tonic-gate 	int		dca_error;
346*7c478bd9Sstevel@tonic-gate 	int		dca_flags;
347*7c478bd9Sstevel@tonic-gate 	char		dca_name[PATH_MAX+MAXNAMELEN];
348*7c478bd9Sstevel@tonic-gate };
349*7c478bd9Sstevel@tonic-gate 
350*7c478bd9Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_init(const char *name, uint_t flags);
351*7c478bd9Sstevel@tonic-gate extern int di_devlink_walk(di_devlink_handle_t hdl, const char *re,
352*7c478bd9Sstevel@tonic-gate     const char *minor_path, uint_t flags, void *arg,
353*7c478bd9Sstevel@tonic-gate     int (*devlink_callback)(di_devlink_t, void *));
354*7c478bd9Sstevel@tonic-gate extern const char *di_devlink_path(di_devlink_t devlink);
355*7c478bd9Sstevel@tonic-gate extern const char *di_devlink_content(di_devlink_t devlink);
356*7c478bd9Sstevel@tonic-gate extern int di_devlink_type(di_devlink_t devlink);
357*7c478bd9Sstevel@tonic-gate extern di_devlink_t di_devlink_dup(di_devlink_t devlink);
358*7c478bd9Sstevel@tonic-gate extern int di_devlink_free(di_devlink_t devlink);
359*7c478bd9Sstevel@tonic-gate extern int di_devlink_fini(di_devlink_handle_t *hdlp);
360*7c478bd9Sstevel@tonic-gate 
361*7c478bd9Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_open(const char *root_dir, uint_t flags);
362*7c478bd9Sstevel@tonic-gate extern int di_devlink_close(di_devlink_handle_t *pp, int flag);
363*7c478bd9Sstevel@tonic-gate extern int di_devlink_rm_link(di_devlink_handle_t hdp, const char *link);
364*7c478bd9Sstevel@tonic-gate extern int di_devlink_add_link(di_devlink_handle_t hdp, const char *link,
365*7c478bd9Sstevel@tonic-gate     const char *content, int flags);
366*7c478bd9Sstevel@tonic-gate extern int di_devlink_update(di_devlink_handle_t hdp);
367*7c478bd9Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_init_root(const char *root,
368*7c478bd9Sstevel@tonic-gate     const char *name, uint_t flags);
369*7c478bd9Sstevel@tonic-gate extern int di_devlink_cache_walk(di_devlink_handle_t hdp, const char *re,
370*7c478bd9Sstevel@tonic-gate     const char *path, uint_t flags, void *arg,
371*7c478bd9Sstevel@tonic-gate     int (*devlink_callback)(di_devlink_t, void *));
372*7c478bd9Sstevel@tonic-gate 
373*7c478bd9Sstevel@tonic-gate /*
374*7c478bd9Sstevel@tonic-gate  * Private interfaces for /etc/logindevperm
375*7c478bd9Sstevel@tonic-gate  */
376*7c478bd9Sstevel@tonic-gate extern int di_devperm_login(const char *, uid_t, gid_t, void (*)(char *));
377*7c478bd9Sstevel@tonic-gate extern int di_devperm_logout(const char *);
378*7c478bd9Sstevel@tonic-gate 
379*7c478bd9Sstevel@tonic-gate /*
380*7c478bd9Sstevel@tonic-gate  * Private interface for looking up a node in a snapshot
381*7c478bd9Sstevel@tonic-gate  */
382*7c478bd9Sstevel@tonic-gate extern di_node_t di_lookup_node(di_node_t root, char *path);
383*7c478bd9Sstevel@tonic-gate 
384*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
385*7c478bd9Sstevel@tonic-gate }
386*7c478bd9Sstevel@tonic-gate #endif
387*7c478bd9Sstevel@tonic-gate 
388*7c478bd9Sstevel@tonic-gate #endif	/* _LIBDEVINFO_H */
389