xref: /onnv-gate/usr/src/lib/libdevinfo/libdevinfo.h (revision 12116:ea985fb42600)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52587Spjha  * Common Development and Distribution License (the "License").
62587Spjha  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*12116SVikram.Hegde@Sun.COM  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef	_LIBDEVINFO_H
260Sstevel@tonic-gate #define	_LIBDEVINFO_H
270Sstevel@tonic-gate 
282621Sllai1 #ifdef	__cplusplus
292621Sllai1 extern "C" {
302621Sllai1 #endif
312621Sllai1 
320Sstevel@tonic-gate #include <errno.h>
332621Sllai1 #include <libnvpair.h>
340Sstevel@tonic-gate #include <sys/param.h>
350Sstevel@tonic-gate #include <sys/sunddi.h>
360Sstevel@tonic-gate #include <sys/sunmdi.h>
370Sstevel@tonic-gate #include <sys/openpromio.h>
380Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
390Sstevel@tonic-gate #include <sys/devinfo_impl.h>
400Sstevel@tonic-gate #include <limits.h>
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * flags for di_walk_node
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate #define	DI_WALK_CLDFIRST	0
460Sstevel@tonic-gate #define	DI_WALK_SIBFIRST	1
470Sstevel@tonic-gate #define	DI_WALK_LINKGEN		2
480Sstevel@tonic-gate 
490Sstevel@tonic-gate #define	DI_WALK_MASK		0xf
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate  * flags for di_walk_link
530Sstevel@tonic-gate  */
540Sstevel@tonic-gate #define	DI_LINK_SRC		1
550Sstevel@tonic-gate #define	DI_LINK_TGT		2
560Sstevel@tonic-gate 
570Sstevel@tonic-gate /*
580Sstevel@tonic-gate  * return code for node_callback
590Sstevel@tonic-gate  */
600Sstevel@tonic-gate #define	DI_WALK_CONTINUE	0
610Sstevel@tonic-gate #define	DI_WALK_PRUNESIB	-1
620Sstevel@tonic-gate #define	DI_WALK_PRUNECHILD	-2
630Sstevel@tonic-gate #define	DI_WALK_TERMINATE	-3
640Sstevel@tonic-gate 
650Sstevel@tonic-gate /*
660Sstevel@tonic-gate  * flags for di_walk_minor
670Sstevel@tonic-gate  */
680Sstevel@tonic-gate #define	DI_CHECK_ALIAS		0x10
690Sstevel@tonic-gate #define	DI_CHECK_INTERNAL_PATH	0x20
700Sstevel@tonic-gate 
710Sstevel@tonic-gate #define	DI_CHECK_MASK		0xf0
720Sstevel@tonic-gate 
7310923SEvan.Yan@Sun.COM /*
7410923SEvan.Yan@Sun.COM  * flags for di_walk_hp
7510923SEvan.Yan@Sun.COM  */
7610923SEvan.Yan@Sun.COM #define	DI_HP_CONNECTOR		0x1
7710923SEvan.Yan@Sun.COM #define	DI_HP_PORT		0x2
7810923SEvan.Yan@Sun.COM 
790Sstevel@tonic-gate /* nodeid types */
800Sstevel@tonic-gate #define	DI_PSEUDO_NODEID	-1
810Sstevel@tonic-gate #define	DI_SID_NODEID		-2
820Sstevel@tonic-gate #define	DI_PROM_NODEID		-3
830Sstevel@tonic-gate 
840Sstevel@tonic-gate /* node & device states */
850Sstevel@tonic-gate #define	DI_DRIVER_DETACHED	0x8000
860Sstevel@tonic-gate #define	DI_DEVICE_OFFLINE	0x1
870Sstevel@tonic-gate #define	DI_DEVICE_DOWN		0x2
887275Sstephh #define	DI_DEVICE_DEGRADED	0x4
8910696SDavid.Hollister@Sun.COM #define	DI_DEVICE_REMOVED	0x8
900Sstevel@tonic-gate #define	DI_BUS_QUIESCED		0x100
910Sstevel@tonic-gate #define	DI_BUS_DOWN		0x200
920Sstevel@tonic-gate 
930Sstevel@tonic-gate /* property types */
940Sstevel@tonic-gate #define	DI_PROP_TYPE_BOOLEAN	0
950Sstevel@tonic-gate #define	DI_PROP_TYPE_INT	1
960Sstevel@tonic-gate #define	DI_PROP_TYPE_STRING	2
970Sstevel@tonic-gate #define	DI_PROP_TYPE_BYTE	3
980Sstevel@tonic-gate #define	DI_PROP_TYPE_UNKNOWN	4
990Sstevel@tonic-gate #define	DI_PROP_TYPE_UNDEF_IT	5
1000Sstevel@tonic-gate #define	DI_PROP_TYPE_INT64	6
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate /* private macro for checking if a prop type is valid */
1030Sstevel@tonic-gate #define	DI_PROP_TYPE_VALID(type) \
1040Sstevel@tonic-gate 	((((type) >= DI_PROP_TYPE_INT) && ((type) <= DI_PROP_TYPE_BYTE)) || \
1050Sstevel@tonic-gate 	    ((type) == DI_PROP_TYPE_INT64))
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate /* opaque handles */
1086640Scth typedef struct di_node		*di_node_t;		/* node */
1096640Scth typedef struct di_minor		*di_minor_t;		/* minor_node */
1106640Scth typedef struct di_path		*di_path_t;		/* path_node */
1116640Scth typedef struct di_link		*di_link_t;		/* link */
1126640Scth typedef struct di_lnode		*di_lnode_t;		/* endpoint */
1136640Scth typedef struct di_devlink	*di_devlink_t;		/* devlink */
11410923SEvan.Yan@Sun.COM typedef struct di_hp		*di_hp_t;		/* hotplug */
1150Sstevel@tonic-gate 
1166640Scth typedef struct di_prop		*di_prop_t;		/* node property */
1176640Scth typedef struct di_path_prop	*di_path_prop_t;	/* path property */
1186640Scth typedef struct di_prom_prop	*di_prom_prop_t;	/* prom property */
1190Sstevel@tonic-gate 
1206640Scth typedef struct di_prom_handle	*di_prom_handle_t;	/* prom snapshot */
1210Sstevel@tonic-gate typedef struct di_devlink_handle *di_devlink_handle_t;	/* devlink snapshot */
1226640Scth 
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate  * Null handles to make handles really opaque
1260Sstevel@tonic-gate  */
1276640Scth #define	DI_NODE_NIL		NULL
1286640Scth #define	DI_MINOR_NIL		NULL
1296640Scth #define	DI_PATH_NIL		NULL
1306640Scth #define	DI_LINK_NIL		NULL
1316640Scth #define	DI_LNODE_NIL		NULL
1326640Scth #define	DI_PROP_NIL		NULL
1330Sstevel@tonic-gate #define	DI_PROM_PROP_NIL	NULL
1340Sstevel@tonic-gate #define	DI_PROM_HANDLE_NIL	NULL
13510923SEvan.Yan@Sun.COM #define	DI_HP_NIL		NULL
1360Sstevel@tonic-gate 
1373814Sjveta /*
1383814Sjveta  * IEEE 1275 properties and other standardized property names
1393814Sjveta  */
1403814Sjveta #define	DI_PROP_FIRST_CHAS	"first-in-chassis"
1413814Sjveta #define	DI_PROP_SLOT_NAMES	"slot-names"
1423814Sjveta #define	DI_PROP_PHYS_SLOT	"physical-slot#"
1433814Sjveta #define	DI_PROP_DEV_TYPE	"device_type"
1443814Sjveta #define	DI_PROP_BUS_RANGE	"bus-range"
1453814Sjveta #define	DI_PROP_SERID		"serialid#"
1463814Sjveta #define	DI_PROP_REG		"reg"
1473814Sjveta #define	DI_PROP_AP_NAMES	"ap-names"
1483814Sjveta 
1490Sstevel@tonic-gate /* Interface Prototypes */
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate /*
1520Sstevel@tonic-gate  * Snapshot initialization and cleanup
1530Sstevel@tonic-gate  */
1546640Scth extern di_node_t	di_init(const char *phys_path, uint_t flag);
1556640Scth extern void		di_fini(di_node_t root);
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate /*
1586640Scth  * node: traversal, data access, and parameters
1590Sstevel@tonic-gate  */
1606640Scth extern int		di_walk_node(di_node_t root, uint_t flag, void *arg,
1616640Scth 			    int (*node_callback)(di_node_t node, void *arg));
1626640Scth 
1636640Scth extern di_node_t	di_drv_first_node(const char *drv_name, di_node_t root);
1646640Scth extern di_node_t	di_drv_next_node(di_node_t node);
1656640Scth 
1666640Scth extern di_node_t	di_parent_node(di_node_t node);
1676640Scth extern di_node_t	di_sibling_node(di_node_t node);
1686640Scth extern di_node_t	di_child_node(di_node_t node);
1690Sstevel@tonic-gate 
1706640Scth extern char		*di_node_name(di_node_t node);
1716640Scth extern char		*di_bus_addr(di_node_t node);
1726640Scth extern char		*di_binding_name(di_node_t node);
1736640Scth extern int		di_compatible_names(di_node_t, char **names);
1746640Scth extern int		di_instance(di_node_t node);
1756640Scth extern int		di_nodeid(di_node_t node);
1766640Scth extern int		di_driver_major(di_node_t node);
1776640Scth extern uint_t		di_state(di_node_t node);
1786640Scth extern ddi_node_state_t	di_node_state(di_node_t node);
1796640Scth extern ddi_devid_t	di_devid(di_node_t node);
1806640Scth extern char		*di_driver_name(di_node_t node);
1816640Scth extern uint_t		di_driver_ops(di_node_t node);
1820Sstevel@tonic-gate 
1836640Scth extern void		di_node_private_set(di_node_t node, void *data);
1846640Scth extern void		*di_node_private_get(di_node_t node);
1850Sstevel@tonic-gate 
1866640Scth extern char		*di_devfs_path(di_node_t node);
1876640Scth extern char		*di_devfs_minor_path(di_minor_t minor);
1886640Scth extern void		di_devfs_path_free(char *path_buf);
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate /*
1916640Scth  * path_node: traversal, data access, and parameters
1920Sstevel@tonic-gate  */
1936640Scth extern di_path_t	di_path_phci_next_path(di_node_t node, di_path_t);
1946640Scth extern di_path_t	di_path_client_next_path(di_node_t node, di_path_t);
1956640Scth 
1966640Scth extern di_node_t	di_path_phci_node(di_path_t path);
1976640Scth extern di_node_t	di_path_client_node(di_path_t path);
1980Sstevel@tonic-gate 
1996640Scth extern char		*di_path_node_name(di_path_t path);
2006640Scth extern char		*di_path_bus_addr(di_path_t path);
2016640Scth extern int		di_path_instance(di_path_t path);
2026640Scth extern di_path_state_t	di_path_state(di_path_t path);
20310696SDavid.Hollister@Sun.COM extern uint_t		di_path_flags(di_path_t path);
2040Sstevel@tonic-gate 
2056640Scth extern char		*di_path_devfs_path(di_path_t path);
2066640Scth extern char		*di_path_client_devfs_path(di_path_t path);
2076640Scth 
2086640Scth extern void		di_path_private_set(di_path_t path, void *data);
2096640Scth extern void		*di_path_private_get(di_path_t path);
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate /*
2126640Scth  * minor_node: traversal, data access, and parameters
2130Sstevel@tonic-gate  */
2146640Scth extern int		di_walk_minor(di_node_t root, const char *minortype,
2156640Scth 			    uint_t flag, void *arg,
2166640Scth 			    int (*minor_callback)(di_node_t node,
2176640Scth 			    di_minor_t minor, void *arg));
2180Sstevel@tonic-gate extern di_minor_t	di_minor_next(di_node_t node, di_minor_t minor);
2196640Scth 
2200Sstevel@tonic-gate extern di_node_t	di_minor_devinfo(di_minor_t minor);
2210Sstevel@tonic-gate extern ddi_minor_type	di_minor_type(di_minor_t minor);
2220Sstevel@tonic-gate extern char		*di_minor_name(di_minor_t minor);
2230Sstevel@tonic-gate extern dev_t		di_minor_devt(di_minor_t minor);
2240Sstevel@tonic-gate extern int		di_minor_spectype(di_minor_t minor);
2250Sstevel@tonic-gate extern char		*di_minor_nodetype(di_minor_t node);
2260Sstevel@tonic-gate 
2276640Scth extern void		di_minor_private_set(di_minor_t minor, void *data);
2286640Scth extern void		*di_minor_private_get(di_minor_t minor);
2296640Scth 
2300Sstevel@tonic-gate /*
2316640Scth  * node: property access
2320Sstevel@tonic-gate  */
2336640Scth extern di_prop_t	di_prop_next(di_node_t node, di_prop_t prop);
2346640Scth 
2356640Scth extern char		*di_prop_name(di_prop_t prop);
2366640Scth extern int		di_prop_type(di_prop_t prop);
2376640Scth extern dev_t		di_prop_devt(di_prop_t prop);
2386640Scth 
2396640Scth extern int		di_prop_ints(di_prop_t prop, int **prop_data);
2406640Scth extern int		di_prop_int64(di_prop_t prop, int64_t **prop_data);
2416640Scth extern int		di_prop_strings(di_prop_t prop, char **prop_data);
2426640Scth extern int		di_prop_bytes(di_prop_t prop, uchar_t **prop_data);
2436640Scth 
2446640Scth extern int		di_prop_lookup_bytes(dev_t dev, di_node_t node,
2456640Scth 			    const char *prop_name, uchar_t **prop_data);
2466640Scth extern int		di_prop_lookup_ints(dev_t dev, di_node_t node,
2476640Scth 			    const char *prop_name, int **prop_data);
2486640Scth extern int		di_prop_lookup_int64(dev_t dev, di_node_t node,
2496640Scth 			    const char *prop_name, int64_t **prop_data);
2506640Scth extern int		di_prop_lookup_strings(dev_t dev, di_node_t node,
2516640Scth 			    const char *prop_name, char **prop_data);
2526640Scth 
2536640Scth /*
2546640Scth  * prom_node: property access
2556640Scth  */
2566640Scth extern di_prom_handle_t	di_prom_init(void);
2576640Scth extern void		di_prom_fini(di_prom_handle_t ph);
2586640Scth 
2596640Scth extern di_prom_prop_t	di_prom_prop_next(di_prom_handle_t ph, di_node_t node,
2606640Scth 			    di_prom_prop_t prom_prop);
2616640Scth 
2626640Scth extern char		*di_prom_prop_name(di_prom_prop_t prom_prop);
2636640Scth extern int		di_prom_prop_data(di_prom_prop_t prop,
2646640Scth 			    uchar_t **prom_prop_data);
2656640Scth 
2666640Scth extern int		di_prom_prop_lookup_ints(di_prom_handle_t prom,
2676640Scth 			    di_node_t node, const char *prom_prop_name,
2686640Scth 			    int **prom_prop_data);
2696640Scth extern int		di_prom_prop_lookup_strings(di_prom_handle_t prom,
2706640Scth 			    di_node_t node, const char *prom_prop_name,
2716640Scth 			    char **prom_prop_data);
2726640Scth extern int		di_prom_prop_lookup_bytes(di_prom_handle_t prom,
2736640Scth 			    di_node_t node, const char *prom_prop_name,
2746640Scth 			    uchar_t **prom_prop_data);
2750Sstevel@tonic-gate 
2760Sstevel@tonic-gate /*
2776640Scth  * path_node: property access
2780Sstevel@tonic-gate  */
2796640Scth extern di_path_prop_t	di_path_prop_next(di_path_t path, di_path_prop_t prop);
2806640Scth 
2816640Scth extern char		*di_path_prop_name(di_path_prop_t prop);
2826640Scth extern int		di_path_prop_type(di_path_prop_t prop);
2836640Scth extern int		di_path_prop_len(di_path_prop_t prop);
2840Sstevel@tonic-gate 
2856640Scth extern int		di_path_prop_bytes(di_path_prop_t prop,
2866640Scth 			    uchar_t **prop_data);
2876640Scth extern int		di_path_prop_ints(di_path_prop_t prop,
2886640Scth 			    int **prop_data);
2896640Scth extern int		di_path_prop_int64s(di_path_prop_t prop,
2906640Scth 			    int64_t **prop_data);
2916640Scth extern int		di_path_prop_strings(di_path_prop_t prop,
2926640Scth 			    char **prop_data);
2936640Scth 
2946640Scth extern int		di_path_prop_lookup_bytes(di_path_t path,
2956640Scth 			    const char *prop_name, uchar_t **prop_data);
2966640Scth extern int		di_path_prop_lookup_ints(di_path_t path,
2976640Scth 			    const char *prop_name, int **prop_data);
2986640Scth extern int		di_path_prop_lookup_int64s(di_path_t path,
2996640Scth 			    const char *prop_name, int64_t **prop_data);
3006640Scth extern int		di_path_prop_lookup_strings(di_path_t path,
3016640Scth 			    const char *prop_name, char **prop_data);
3020Sstevel@tonic-gate 
3036640Scth /*
3046640Scth  * layering link/lnode: traversal, data access, and parameters
3056640Scth  */
3066640Scth extern int		di_walk_link(di_node_t root, uint_t flag,
3076640Scth 			    uint_t endpoint, void *arg,
3086640Scth 			    int (*link_callback)(di_link_t link, void *arg));
3096640Scth extern int		di_walk_lnode(di_node_t root, uint_t flag, void *arg,
3106640Scth 			    int (*lnode_callback)(di_lnode_t lnode, void *arg));
3110Sstevel@tonic-gate 
3126640Scth extern di_link_t	di_link_next_by_node(di_node_t node,
3136640Scth 			    di_link_t link, uint_t endpoint);
3146640Scth extern di_link_t	di_link_next_by_lnode(di_lnode_t lnode,
3156640Scth 			    di_link_t link, uint_t endpoint);
3166640Scth extern di_lnode_t	di_lnode_next(di_node_t node, di_lnode_t lnode);
3176640Scth extern char		*di_lnode_name(di_lnode_t lnode);
3186640Scth 
3196640Scth extern int		di_link_spectype(di_link_t link);
3206640Scth extern di_lnode_t	di_link_to_lnode(di_link_t link, uint_t endpoint);
3216640Scth 
3226640Scth extern di_node_t	di_lnode_devinfo(di_lnode_t lnode);
3236640Scth extern int		di_lnode_devt(di_lnode_t lnode, dev_t *devt);
3246640Scth 
3256640Scth extern void		di_link_private_set(di_link_t link, void *data);
3266640Scth extern void		*di_link_private_get(di_link_t link);
3276640Scth extern void		di_lnode_private_set(di_lnode_t lnode, void *data);
3286640Scth extern void		*di_lnode_private_get(di_lnode_t lnode);
3296640Scth 
33010923SEvan.Yan@Sun.COM /*
33110923SEvan.Yan@Sun.COM  * hp_node: traversal, data access, and parameters
33210923SEvan.Yan@Sun.COM  */
33310923SEvan.Yan@Sun.COM extern int		di_walk_hp(di_node_t node, const char *type,
33410923SEvan.Yan@Sun.COM 			    uint_t flag, void *arg,
33510923SEvan.Yan@Sun.COM 			    int (*hp_callback)(di_node_t node, di_hp_t hp,
33610923SEvan.Yan@Sun.COM 			    void *arg));
33710923SEvan.Yan@Sun.COM extern di_hp_t		di_hp_next(di_node_t node, di_hp_t hp);
33810923SEvan.Yan@Sun.COM 
33910923SEvan.Yan@Sun.COM extern char		*di_hp_name(di_hp_t hp);
34010923SEvan.Yan@Sun.COM extern int		di_hp_connection(di_hp_t hp);
34110923SEvan.Yan@Sun.COM extern int		di_hp_depends_on(di_hp_t hp);
34210923SEvan.Yan@Sun.COM extern int		di_hp_state(di_hp_t hp);
34310923SEvan.Yan@Sun.COM extern int		di_hp_type(di_hp_t hp);
34410923SEvan.Yan@Sun.COM extern char		*di_hp_description(di_hp_t hp);
34510923SEvan.Yan@Sun.COM extern time_t		di_hp_last_change(di_hp_t hp);
34610923SEvan.Yan@Sun.COM extern di_node_t	di_hp_child(di_hp_t hp);
3470Sstevel@tonic-gate 
3480Sstevel@tonic-gate /*
3490Sstevel@tonic-gate  * Private interfaces
3500Sstevel@tonic-gate  *
3510Sstevel@tonic-gate  * The interfaces and structures below are private to this implementation
3520Sstevel@tonic-gate  * of Solaris and are subject to change at any time without notice.
3530Sstevel@tonic-gate  *
3546640Scth  * Applications and drivers using these interfaces may fail
3550Sstevel@tonic-gate  * to run on future releases.
3560Sstevel@tonic-gate  */
3573814Sjveta extern di_prop_t di_prop_find(dev_t match_dev, di_node_t node,
3583814Sjveta     const char *name);
3596640Scth extern int di_devfs_path_match(const char *dp1, const char *dp2);
3606640Scth 
3616640Scth extern di_node_t	di_vhci_first_node(di_node_t root);
3626640Scth extern di_node_t	di_vhci_next_node(di_node_t node);
3636640Scth extern di_node_t	di_phci_first_node(di_node_t vhci_node);
3646640Scth extern di_node_t	di_phci_next_node(di_node_t node);
3653814Sjveta 
3663814Sjveta /*
3673814Sjveta  * Interfaces for handling IEEE 1275 and other standardized properties
3683814Sjveta  */
3693814Sjveta 
3703814Sjveta /* structure for a single slot */
3713814Sjveta typedef struct di_slot_name {
3723814Sjveta 	int num;	/* corresponding pci device number */
3733814Sjveta 	char *name;
3743814Sjveta } di_slot_name_t;
3753814Sjveta 
3763814Sjveta extern void di_slot_names_free(int count, di_slot_name_t *slot_names);
3773814Sjveta extern int di_slot_names_decode(uchar_t *rawdata, int rawlen,
3783814Sjveta     di_slot_name_t **prop_data);
3793814Sjveta extern int di_prop_slot_names(di_prop_t prop, di_slot_name_t **prop_data);
3803814Sjveta extern int di_prom_prop_slot_names(di_prom_prop_t prom_prop,
3813814Sjveta     di_slot_name_t **prop_data);
3823814Sjveta extern int di_prop_lookup_slot_names(dev_t dev, di_node_t node,
3833814Sjveta     di_slot_name_t **prop_data);
3843814Sjveta extern int di_prom_prop_lookup_slot_names(di_prom_handle_t ph, di_node_t node,
3853814Sjveta     di_slot_name_t **prop_data);
3863814Sjveta 
3870Sstevel@tonic-gate /*
3886640Scth  * XXX Remove the private di_path_(addr,next,next_phci,next_client) interfaces
3896640Scth  * below after NWS consolidation switches to using di_path_bus_addr,
3906640Scth  * di_path_phci_next_path, and di_path_client_next_path per CR6638521.
3910Sstevel@tonic-gate  */
3926640Scth extern char *di_path_addr(di_path_t path, char *buf);
3930Sstevel@tonic-gate extern di_path_t di_path_next(di_node_t node, di_path_t path);
3940Sstevel@tonic-gate extern di_path_t di_path_next_phci(di_node_t node, di_path_t path);
3950Sstevel@tonic-gate extern di_path_t di_path_next_client(di_node_t node, di_path_t path);
3960Sstevel@tonic-gate 
3970Sstevel@tonic-gate /*
3980Sstevel@tonic-gate  * Interfaces for private data
3990Sstevel@tonic-gate  */
4000Sstevel@tonic-gate extern di_node_t di_init_driver(const char *drv_name, uint_t flag);
4010Sstevel@tonic-gate extern di_node_t di_init_impl(const char *phys_path, uint_t flag,
4020Sstevel@tonic-gate     struct di_priv_data *priv_data);
4030Sstevel@tonic-gate 
4040Sstevel@tonic-gate /*
4050Sstevel@tonic-gate  * Prtconf needs to know property lists, raw prop_data, and private data
4060Sstevel@tonic-gate  */
4070Sstevel@tonic-gate extern di_prop_t di_prop_drv_next(di_node_t node, di_prop_t prop);
4080Sstevel@tonic-gate extern di_prop_t di_prop_sys_next(di_node_t node, di_prop_t prop);
4090Sstevel@tonic-gate extern di_prop_t di_prop_global_next(di_node_t node, di_prop_t prop);
4100Sstevel@tonic-gate extern di_prop_t di_prop_hw_next(di_node_t node, di_prop_t prop);
4110Sstevel@tonic-gate 
4120Sstevel@tonic-gate extern int di_prop_rawdata(di_prop_t prop, uchar_t **prop_data);
4130Sstevel@tonic-gate extern void *di_parent_private_data(di_node_t node);
4140Sstevel@tonic-gate extern void *di_driver_private_data(di_node_t node);
4150Sstevel@tonic-gate 
4160Sstevel@tonic-gate /*
4174845Svikram  * The value of the dip's devi_flags field
4184845Svikram  */
4194845Svikram uint_t di_flags(di_node_t node);
4204845Svikram 
4214845Svikram /*
4220Sstevel@tonic-gate  * Types of links for devlink lookup
4230Sstevel@tonic-gate  */
4240Sstevel@tonic-gate #define	DI_PRIMARY_LINK		0x01
4250Sstevel@tonic-gate #define	DI_SECONDARY_LINK	0x02
4260Sstevel@tonic-gate #define	DI_LINK_TYPES		0x03
4270Sstevel@tonic-gate 
4280Sstevel@tonic-gate /*
4290Sstevel@tonic-gate  * Flag for di_devlink_init()
4300Sstevel@tonic-gate  */
4310Sstevel@tonic-gate #define	DI_MAKE_LINK	0x01
4320Sstevel@tonic-gate 
4330Sstevel@tonic-gate /*
4340Sstevel@tonic-gate  * Flag for di_devlink_close()
4350Sstevel@tonic-gate  */
4360Sstevel@tonic-gate #define	DI_LINK_ERROR	0x01
4370Sstevel@tonic-gate 
4380Sstevel@tonic-gate /*
4390Sstevel@tonic-gate  * For devfsadm synchronous link creation interfaces
4400Sstevel@tonic-gate  */
4410Sstevel@tonic-gate #define	DEVFSADM_SYNCH_DOOR	".devfsadm_synch_door"
4420Sstevel@tonic-gate 
4430Sstevel@tonic-gate /*
4440Sstevel@tonic-gate  * devlink create argument
4450Sstevel@tonic-gate  */
4460Sstevel@tonic-gate struct dca_off {
4470Sstevel@tonic-gate 	uint32_t	dca_root;
4480Sstevel@tonic-gate 	uint32_t	dca_minor;
4490Sstevel@tonic-gate 	uint32_t	dca_driver;
4500Sstevel@tonic-gate 	int		dca_error;
4510Sstevel@tonic-gate 	int		dca_flags;
4520Sstevel@tonic-gate 	char		dca_name[PATH_MAX+MAXNAMELEN];
4530Sstevel@tonic-gate };
4540Sstevel@tonic-gate 
4550Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_init(const char *name, uint_t flags);
4560Sstevel@tonic-gate extern int di_devlink_walk(di_devlink_handle_t hdl, const char *re,
4570Sstevel@tonic-gate     const char *minor_path, uint_t flags, void *arg,
4580Sstevel@tonic-gate     int (*devlink_callback)(di_devlink_t, void *));
4590Sstevel@tonic-gate extern const char *di_devlink_path(di_devlink_t devlink);
4600Sstevel@tonic-gate extern const char *di_devlink_content(di_devlink_t devlink);
4610Sstevel@tonic-gate extern int di_devlink_type(di_devlink_t devlink);
4620Sstevel@tonic-gate extern di_devlink_t di_devlink_dup(di_devlink_t devlink);
4630Sstevel@tonic-gate extern int di_devlink_free(di_devlink_t devlink);
4640Sstevel@tonic-gate extern int di_devlink_fini(di_devlink_handle_t *hdlp);
4650Sstevel@tonic-gate 
4660Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_open(const char *root_dir, uint_t flags);
4670Sstevel@tonic-gate extern int di_devlink_close(di_devlink_handle_t *pp, int flag);
4680Sstevel@tonic-gate extern int di_devlink_rm_link(di_devlink_handle_t hdp, const char *link);
4690Sstevel@tonic-gate extern int di_devlink_add_link(di_devlink_handle_t hdp, const char *link,
4700Sstevel@tonic-gate     const char *content, int flags);
4710Sstevel@tonic-gate extern int di_devlink_update(di_devlink_handle_t hdp);
4720Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_init_root(const char *root,
4730Sstevel@tonic-gate     const char *name, uint_t flags);
4740Sstevel@tonic-gate extern int di_devlink_cache_walk(di_devlink_handle_t hdp, const char *re,
4750Sstevel@tonic-gate     const char *path, uint_t flags, void *arg,
4760Sstevel@tonic-gate     int (*devlink_callback)(di_devlink_t, void *));
4770Sstevel@tonic-gate 
4780Sstevel@tonic-gate /*
4794845Svikram  * Private interfaces for I/O retire
4804845Svikram  */
4814845Svikram typedef struct di_retire {
4824845Svikram 	void	*rt_hdl;
4834845Svikram 	void	(*rt_abort)(void *hdl, const char *format, ...);
4844845Svikram 	void	(*rt_debug)(void *hdl, const char *format, ...);
4854845Svikram } di_retire_t;
4864845Svikram 
4874845Svikram extern int di_retire_device(char *path, di_retire_t *dp, int flags);
4884845Svikram extern int di_unretire_device(char *path, di_retire_t *dp);
4894845Svikram extern uint_t di_retired(di_node_t node);
4904845Svikram 
4914845Svikram /*
4920Sstevel@tonic-gate  * Private interfaces for /etc/logindevperm
4930Sstevel@tonic-gate  */
4940Sstevel@tonic-gate extern int di_devperm_login(const char *, uid_t, gid_t, void (*)(char *));
4950Sstevel@tonic-gate extern int di_devperm_logout(const char *);
4960Sstevel@tonic-gate 
4970Sstevel@tonic-gate /*
4986640Scth  * Private interface for looking up, by path string, a node/path/minor
4996640Scth  * in a snapshot.
5000Sstevel@tonic-gate  */
5016640Scth extern di_path_t di_lookup_path(di_node_t root, char *path);
5020Sstevel@tonic-gate extern di_node_t di_lookup_node(di_node_t root, char *path);
5030Sstevel@tonic-gate 
5042587Spjha /*
5052587Spjha  * Private hotplug interfaces to be used between cfgadm pci plugin and
5062587Spjha  * devfsadm link generator.
5072587Spjha  */
5082587Spjha extern char *di_dli_name(char *);
5092587Spjha extern int di_dli_openr(char *);
5102587Spjha extern int di_dli_openw(char *);
5112587Spjha extern void di_dli_close(int);
5122587Spjha 
5132621Sllai1 /*
5144870Sjg  * Private interface for parsing path_to_inst binding file
5154870Sjg  */
5164870Sjg extern int devfs_parse_binding_file(const char *,
5174870Sjg 	int (*)(void *, const char *, int, const char *), void *);
5184870Sjg extern int devfs_walk_minor_nodes(const char *,
5194870Sjg 	int (*)(void *, const char *), void *);
5204870Sjg 
5214870Sjg /*
5222621Sllai1  * finddev - alternate readdir to discover only /dev persisted device names
5232621Sllai1  */
5242621Sllai1 typedef struct __finddevhdl *finddevhdl_t;
5252621Sllai1 
5262621Sllai1 extern int		device_exists(const char *);
5272621Sllai1 extern int		finddev_readdir(const char *, finddevhdl_t *);
5286065Scth extern int		finddev_emptydir(const char *);
5292621Sllai1 extern void		finddev_close(finddevhdl_t);
5302621Sllai1 extern const char	*finddev_next(finddevhdl_t);
5312621Sllai1 
5322621Sllai1 
5332621Sllai1 /*
5342621Sllai1  * Private interfaces for non-global /dev profile
5352621Sllai1  */
5362621Sllai1 typedef struct __di_prof	*di_prof_t;
5372621Sllai1 
5382621Sllai1 extern int	di_prof_init(const char *mountpt, di_prof_t *);
5392621Sllai1 extern void	di_prof_fini(di_prof_t);
5402621Sllai1 extern int	di_prof_commit(di_prof_t);
5412621Sllai1 extern int	di_prof_add_dev(di_prof_t, const char *);
5422621Sllai1 extern int	di_prof_add_exclude(di_prof_t, const char *);
5432621Sllai1 extern int	di_prof_add_symlink(di_prof_t, const char *, const char *);
5442621Sllai1 extern int	di_prof_add_map(di_prof_t, const char *, const char *);
5452621Sllai1 
5462723Scth /*
5472723Scth  * Private interfaces for <driver><instance><minor> to path conversion.
5482723Scth  * NOTE: These interfaces do not require or cause attach.  The implementation
5492723Scth  * uses the kernel instance-tree (/etc/path_to_inst) and the di_devlinks
5502723Scth  * database information.
5512723Scth  */
5522723Scth typedef struct __di_dim	*di_dim_t;
5532723Scth 
5542723Scth extern di_dim_t	di_dim_init();
5552723Scth extern void	di_dim_fini(di_dim_t);
5562723Scth extern char	*di_dim_path_devices(di_dim_t,
5572723Scth 		    char *drv_name, int instance, char *minor_name);
5582723Scth extern char	*di_dim_path_dev(di_dim_t,
5592723Scth 		    char *drv_name, int instance, char *minor_name);
5602723Scth 
561*12116SVikram.Hegde@Sun.COM /*
562*12116SVikram.Hegde@Sun.COM  * Alias related exported interfaces
563*12116SVikram.Hegde@Sun.COM  */
564*12116SVikram.Hegde@Sun.COM char *di_alias2curr(di_node_t anynode, char *alias);
5652723Scth 
5660Sstevel@tonic-gate #ifdef	__cplusplus
5670Sstevel@tonic-gate }
5680Sstevel@tonic-gate #endif
5690Sstevel@tonic-gate 
5700Sstevel@tonic-gate #endif	/* _LIBDEVINFO_H */
571