17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 53c4226f9Spjha * Common Development and Distribution License (the "License"). 63c4226f9Spjha * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 223c4226f9Spjha * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _LIBDEVINFO_H 277c478bd9Sstevel@tonic-gate #define _LIBDEVINFO_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 31*facf4a8dSllai #ifdef __cplusplus 32*facf4a8dSllai extern "C" { 33*facf4a8dSllai #endif 34*facf4a8dSllai 357c478bd9Sstevel@tonic-gate #include <errno.h> 36*facf4a8dSllai #include <libnvpair.h> 377c478bd9Sstevel@tonic-gate #include <sys/param.h> 387c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 397c478bd9Sstevel@tonic-gate #include <sys/sunmdi.h> 407c478bd9Sstevel@tonic-gate #include <sys/openpromio.h> 417c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 427c478bd9Sstevel@tonic-gate #include <sys/devinfo_impl.h> 437c478bd9Sstevel@tonic-gate #include <limits.h> 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * flags for di_walk_node 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate #define DI_WALK_CLDFIRST 0 497c478bd9Sstevel@tonic-gate #define DI_WALK_SIBFIRST 1 507c478bd9Sstevel@tonic-gate #define DI_WALK_LINKGEN 2 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate #define DI_WALK_MASK 0xf 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* 557c478bd9Sstevel@tonic-gate * flags for di_walk_link 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate #define DI_LINK_SRC 1 587c478bd9Sstevel@tonic-gate #define DI_LINK_TGT 2 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate /* 617c478bd9Sstevel@tonic-gate * return code for node_callback 627c478bd9Sstevel@tonic-gate */ 637c478bd9Sstevel@tonic-gate #define DI_WALK_CONTINUE 0 647c478bd9Sstevel@tonic-gate #define DI_WALK_PRUNESIB -1 657c478bd9Sstevel@tonic-gate #define DI_WALK_PRUNECHILD -2 667c478bd9Sstevel@tonic-gate #define DI_WALK_TERMINATE -3 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * flags for di_walk_minor 707c478bd9Sstevel@tonic-gate */ 717c478bd9Sstevel@tonic-gate #define DI_CHECK_ALIAS 0x10 727c478bd9Sstevel@tonic-gate #define DI_CHECK_INTERNAL_PATH 0x20 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate #define DI_CHECK_MASK 0xf0 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* nodeid types */ 777c478bd9Sstevel@tonic-gate #define DI_PSEUDO_NODEID -1 787c478bd9Sstevel@tonic-gate #define DI_SID_NODEID -2 797c478bd9Sstevel@tonic-gate #define DI_PROM_NODEID -3 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate /* node & device states */ 827c478bd9Sstevel@tonic-gate #define DI_DRIVER_DETACHED 0x8000 837c478bd9Sstevel@tonic-gate #define DI_DEVICE_OFFLINE 0x1 847c478bd9Sstevel@tonic-gate #define DI_DEVICE_DOWN 0x2 857c478bd9Sstevel@tonic-gate #define DI_BUS_QUIESCED 0x100 867c478bd9Sstevel@tonic-gate #define DI_BUS_DOWN 0x200 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* property types */ 897c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_BOOLEAN 0 907c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_INT 1 917c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_STRING 2 927c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_BYTE 3 937c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_UNKNOWN 4 947c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_UNDEF_IT 5 957c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_INT64 6 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* private macro for checking if a prop type is valid */ 987c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_VALID(type) \ 997c478bd9Sstevel@tonic-gate ((((type) >= DI_PROP_TYPE_INT) && ((type) <= DI_PROP_TYPE_BYTE)) || \ 1007c478bd9Sstevel@tonic-gate ((type) == DI_PROP_TYPE_INT64)) 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* opaque handles */ 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate typedef struct di_node *di_node_t; /* opaque handle to node */ 1057c478bd9Sstevel@tonic-gate typedef struct di_minor *di_minor_t; /* opaque handle to minor node */ 1067c478bd9Sstevel@tonic-gate typedef struct di_prop *di_prop_t; /* opaque handle to property */ 1077c478bd9Sstevel@tonic-gate typedef struct di_prom_prop *di_prom_prop_t; /* opaque handle to prom prop */ 1087c478bd9Sstevel@tonic-gate typedef struct di_prom_handle *di_prom_handle_t; /* opaque handle */ 1097c478bd9Sstevel@tonic-gate typedef struct di_path *di_path_t; /* opaque handle */ 1107c478bd9Sstevel@tonic-gate typedef struct di_path_prop *di_path_prop_t; /* opaque handle */ 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate typedef struct di_devlink_handle *di_devlink_handle_t; /* devlink snapshot */ 1137c478bd9Sstevel@tonic-gate typedef struct di_devlink *di_devlink_t; /* opaque handle to devlink */ 1147c478bd9Sstevel@tonic-gate typedef struct di_link *di_link_t; /* opaque handle to link */ 1157c478bd9Sstevel@tonic-gate typedef struct di_lnode *di_lnode_t; /* opaque handle to endpoint */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * Null handles to make handles really opaque 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate #define DI_NODE_NIL NULL 1217c478bd9Sstevel@tonic-gate #define DI_LINK_NIL NULL 1227c478bd9Sstevel@tonic-gate #define DI_LNODE_NIL NULL 1237c478bd9Sstevel@tonic-gate #define DI_MINOR_NIL NULL 1247c478bd9Sstevel@tonic-gate #define DI_PROP_NIL NULL 1257c478bd9Sstevel@tonic-gate #define DI_PROM_PROP_NIL NULL 1267c478bd9Sstevel@tonic-gate #define DI_PROM_HANDLE_NIL NULL 1277c478bd9Sstevel@tonic-gate #define DI_PATH_NIL NULL 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* Interface Prototypes */ 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 1327c478bd9Sstevel@tonic-gate * Snapshot initialization and cleanup 1337c478bd9Sstevel@tonic-gate */ 1347c478bd9Sstevel@tonic-gate extern di_node_t di_init(const char *phys_path, uint_t flag); 1357c478bd9Sstevel@tonic-gate extern void di_fini(di_node_t root); 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* 1387c478bd9Sstevel@tonic-gate * tree traversal 1397c478bd9Sstevel@tonic-gate */ 1407c478bd9Sstevel@tonic-gate extern di_node_t di_parent_node(di_node_t node); 1417c478bd9Sstevel@tonic-gate extern di_node_t di_sibling_node(di_node_t node); 1427c478bd9Sstevel@tonic-gate extern di_node_t di_child_node(di_node_t node); 1437c478bd9Sstevel@tonic-gate extern di_node_t di_drv_first_node(const char *drv_name, di_node_t root); 1447c478bd9Sstevel@tonic-gate extern di_node_t di_drv_next_node(di_node_t node); 1458c4f8890Srs extern di_node_t di_vhci_first_node(di_node_t root); 1468c4f8890Srs extern di_node_t di_vhci_next_node(di_node_t node); 1478c4f8890Srs extern di_node_t di_phci_first_node(di_node_t vhci_node); 1488c4f8890Srs extern di_node_t di_phci_next_node(di_node_t node); 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate /* 1517c478bd9Sstevel@tonic-gate * tree walking assistants 1527c478bd9Sstevel@tonic-gate */ 1537c478bd9Sstevel@tonic-gate extern int di_walk_node(di_node_t root, uint_t flag, void *arg, 1547c478bd9Sstevel@tonic-gate int (*node_callback)(di_node_t node, void *arg)); 1557c478bd9Sstevel@tonic-gate extern int di_walk_minor(di_node_t root, const char *minortype, uint_t flag, 1567c478bd9Sstevel@tonic-gate void *arg, int (*minor_callback)(di_node_t node, di_minor_t minor, 1577c478bd9Sstevel@tonic-gate void *arg)); 1587c478bd9Sstevel@tonic-gate extern int di_walk_link(di_node_t root, uint_t flag, uint_t endpoint, 1597c478bd9Sstevel@tonic-gate void *arg, int (*link_callback)(di_link_t link, void *arg)); 1607c478bd9Sstevel@tonic-gate extern int di_walk_lnode(di_node_t root, uint_t flag, 1617c478bd9Sstevel@tonic-gate void *arg, int (*lnode_callback)(di_lnode_t lnode, void *arg)); 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate extern void di_node_private_set(di_node_t node, void *data); 1647c478bd9Sstevel@tonic-gate extern void *di_node_private_get(di_node_t node); 1657c478bd9Sstevel@tonic-gate extern void di_minor_private_set(di_minor_t minor, void *data); 1667c478bd9Sstevel@tonic-gate extern void *di_minor_private_get(di_minor_t minor); 1677c478bd9Sstevel@tonic-gate extern void di_lnode_private_set(di_lnode_t lnode, void *data); 1687c478bd9Sstevel@tonic-gate extern void *di_lnode_private_get(di_lnode_t lnode); 1697c478bd9Sstevel@tonic-gate extern void di_link_private_set(di_link_t link, void *data); 1707c478bd9Sstevel@tonic-gate extern void *di_link_private_get(di_link_t link); 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate /* 1737c478bd9Sstevel@tonic-gate * generic node parameters 1747c478bd9Sstevel@tonic-gate */ 1757c478bd9Sstevel@tonic-gate extern char *di_node_name(di_node_t node); 1767c478bd9Sstevel@tonic-gate extern char *di_bus_addr(di_node_t node); 1777c478bd9Sstevel@tonic-gate extern char *di_binding_name(di_node_t node); 1787c478bd9Sstevel@tonic-gate extern int di_compatible_names(di_node_t, char **names); 1797c478bd9Sstevel@tonic-gate extern int di_instance(di_node_t node); 1807c478bd9Sstevel@tonic-gate extern int di_nodeid(di_node_t node); 1817c478bd9Sstevel@tonic-gate extern int di_driver_major(di_node_t node); 1827c478bd9Sstevel@tonic-gate extern uint_t di_state(di_node_t node); 1837c478bd9Sstevel@tonic-gate extern ddi_node_state_t di_node_state(di_node_t node); 1847c478bd9Sstevel@tonic-gate extern ddi_devid_t di_devid(di_node_t node); 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate extern char *di_driver_name(di_node_t node); 1877c478bd9Sstevel@tonic-gate extern uint_t di_driver_ops(di_node_t node); 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate extern char *di_devfs_path(di_node_t node); 1907c478bd9Sstevel@tonic-gate extern char *di_devfs_minor_path(di_minor_t minor); 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate extern void di_devfs_path_free(char *path_buf); 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate /* 1957c478bd9Sstevel@tonic-gate * layering data access 1967c478bd9Sstevel@tonic-gate */ 1977c478bd9Sstevel@tonic-gate extern di_link_t di_link_next_by_node(di_node_t node, 1987c478bd9Sstevel@tonic-gate di_link_t link, uint_t endpoint); 1997c478bd9Sstevel@tonic-gate extern di_link_t di_link_next_by_lnode(di_lnode_t lnode, 2007c478bd9Sstevel@tonic-gate di_link_t link, uint_t endpoint); 2017c478bd9Sstevel@tonic-gate extern di_lnode_t di_link_to_lnode(di_link_t link, uint_t endpoint); 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate extern di_lnode_t di_lnode_next(di_node_t node, di_lnode_t lnode); 2047c478bd9Sstevel@tonic-gate extern char *di_lnode_name(di_lnode_t lnode); 2057c478bd9Sstevel@tonic-gate extern di_node_t di_lnode_devinfo(di_lnode_t lnode); 2067c478bd9Sstevel@tonic-gate extern int di_lnode_devt(di_lnode_t lnode, dev_t *devt); 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate extern int di_link_spectype(di_link_t link); 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * minor data access 2127c478bd9Sstevel@tonic-gate */ 2137c478bd9Sstevel@tonic-gate extern di_minor_t di_minor_next(di_node_t node, di_minor_t minor); 2147c478bd9Sstevel@tonic-gate extern di_node_t di_minor_devinfo(di_minor_t minor); 2157c478bd9Sstevel@tonic-gate extern ddi_minor_type di_minor_type(di_minor_t minor); 2167c478bd9Sstevel@tonic-gate extern char *di_minor_name(di_minor_t minor); 2177c478bd9Sstevel@tonic-gate extern dev_t di_minor_devt(di_minor_t minor); 2187c478bd9Sstevel@tonic-gate extern int di_minor_spectype(di_minor_t minor); 2197c478bd9Sstevel@tonic-gate extern char *di_minor_nodetype(di_minor_t node); 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate /* 2227c478bd9Sstevel@tonic-gate * Software property access 2237c478bd9Sstevel@tonic-gate */ 2247c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_next(di_node_t node, di_prop_t prop); 2257c478bd9Sstevel@tonic-gate extern dev_t di_prop_devt(di_prop_t prop); 2267c478bd9Sstevel@tonic-gate extern char *di_prop_name(di_prop_t prop); 2277c478bd9Sstevel@tonic-gate extern int di_prop_type(di_prop_t prop); 2287c478bd9Sstevel@tonic-gate extern int di_prop_ints(di_prop_t prop, int **prop_data); 2297c478bd9Sstevel@tonic-gate extern int di_prop_int64(di_prop_t prop, int64_t **prop_data); 2307c478bd9Sstevel@tonic-gate extern int di_prop_strings(di_prop_t prop, char **prop_data); 2317c478bd9Sstevel@tonic-gate extern int di_prop_bytes(di_prop_t prop, uchar_t **prop_data); 2327c478bd9Sstevel@tonic-gate extern int di_prop_lookup_ints(dev_t dev, di_node_t node, 2337c478bd9Sstevel@tonic-gate const char *prop_name, int **prop_data); 2347c478bd9Sstevel@tonic-gate extern int di_prop_lookup_int64(dev_t dev, di_node_t node, 2357c478bd9Sstevel@tonic-gate const char *prop_name, int64_t **prop_data); 2367c478bd9Sstevel@tonic-gate extern int di_prop_lookup_strings(dev_t dev, di_node_t node, 2377c478bd9Sstevel@tonic-gate const char *prop_name, char **prop_data); 2387c478bd9Sstevel@tonic-gate extern int di_prop_lookup_bytes(dev_t dev, di_node_t node, 2397c478bd9Sstevel@tonic-gate const char *prop_name, uchar_t **prop_data); 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate /* 2427c478bd9Sstevel@tonic-gate * PROM property access 2437c478bd9Sstevel@tonic-gate */ 2447c478bd9Sstevel@tonic-gate extern di_prom_handle_t di_prom_init(void); 2457c478bd9Sstevel@tonic-gate extern void di_prom_fini(di_prom_handle_t ph); 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate extern di_prom_prop_t di_prom_prop_next(di_prom_handle_t ph, di_node_t node, 2487c478bd9Sstevel@tonic-gate di_prom_prop_t prom_prop); 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate extern char *di_prom_prop_name(di_prom_prop_t prom_prop); 2517c478bd9Sstevel@tonic-gate extern int di_prom_prop_data(di_prom_prop_t prop, uchar_t **prom_prop_data); 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate extern int di_prom_prop_lookup_ints(di_prom_handle_t prom, di_node_t node, 2547c478bd9Sstevel@tonic-gate const char *prom_prop_name, int **prom_prop_data); 2557c478bd9Sstevel@tonic-gate extern int di_prom_prop_lookup_strings(di_prom_handle_t prom, di_node_t node, 2567c478bd9Sstevel@tonic-gate const char *prom_prop_name, char **prom_prop_data); 2577c478bd9Sstevel@tonic-gate extern int di_prom_prop_lookup_bytes(di_prom_handle_t prom, di_node_t node, 2587c478bd9Sstevel@tonic-gate const char *prom_prop_name, uchar_t **prom_prop_data); 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate /* 2617c478bd9Sstevel@tonic-gate * Private interfaces 2627c478bd9Sstevel@tonic-gate * 2637c478bd9Sstevel@tonic-gate * The interfaces and structures below are private to this implementation 2647c478bd9Sstevel@tonic-gate * of Solaris and are subject to change at any time without notice. 2657c478bd9Sstevel@tonic-gate * 2667c478bd9Sstevel@tonic-gate * Applications and drivers using these interfaces will fail 2677c478bd9Sstevel@tonic-gate * to run on future releases. 2687c478bd9Sstevel@tonic-gate */ 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate /* 2717c478bd9Sstevel@tonic-gate * Interfaces for accessing I/O multipathing data 2727c478bd9Sstevel@tonic-gate */ 2737c478bd9Sstevel@tonic-gate /* XXX remove di_path_next() after updating NWS consolidation */ 2747c478bd9Sstevel@tonic-gate extern di_path_t di_path_next(di_node_t node, di_path_t path); 2757c478bd9Sstevel@tonic-gate extern di_path_t di_path_next_phci(di_node_t node, di_path_t path); 2767c478bd9Sstevel@tonic-gate extern di_path_t di_path_next_client(di_node_t node, di_path_t path); 2777c478bd9Sstevel@tonic-gate extern di_path_state_t di_path_state(di_path_t path); 2787c478bd9Sstevel@tonic-gate extern char *di_path_addr(di_path_t path, char *buf); 2797c478bd9Sstevel@tonic-gate extern di_node_t di_path_client_node(di_path_t path); 2807c478bd9Sstevel@tonic-gate extern void di_path_client_path(di_path_t path, char *buf); 2817c478bd9Sstevel@tonic-gate extern di_node_t di_path_phci_node(di_path_t path); 2827c478bd9Sstevel@tonic-gate extern void di_path_phci_path(di_path_t path, char *buf); 2837c478bd9Sstevel@tonic-gate extern di_path_prop_t di_path_prop_next(di_path_t path, di_path_prop_t prop); 2847c478bd9Sstevel@tonic-gate extern char *di_path_prop_name(di_path_prop_t prop); 2857c478bd9Sstevel@tonic-gate extern int di_path_prop_type(di_path_prop_t prop); 2867c478bd9Sstevel@tonic-gate extern int di_path_prop_len(di_path_prop_t prop); 2877c478bd9Sstevel@tonic-gate extern int di_path_prop_bytes(di_path_prop_t prop, uchar_t **prop_data); 2887c478bd9Sstevel@tonic-gate extern int di_path_prop_ints(di_path_prop_t prop, int **prop_data); 2897c478bd9Sstevel@tonic-gate extern int di_path_prop_int64s(di_path_prop_t prop, int64_t **prop_data); 2907c478bd9Sstevel@tonic-gate extern int di_path_prop_strings(di_path_prop_t prop, char **prop_data); 2917c478bd9Sstevel@tonic-gate extern int di_path_prop_lookup_bytes(di_path_t path, const char *prop_name, 2927c478bd9Sstevel@tonic-gate uchar_t **prop_data); 2937c478bd9Sstevel@tonic-gate extern int di_path_prop_lookup_ints(di_path_t path, const char *prop_name, 2947c478bd9Sstevel@tonic-gate int **prop_data); 2957c478bd9Sstevel@tonic-gate extern int di_path_prop_lookup_int64s(di_path_t path, const char *prop_name, 2967c478bd9Sstevel@tonic-gate int64_t **prop_data); 2977c478bd9Sstevel@tonic-gate extern int di_path_prop_lookup_strings(di_path_t path, const char *prop_name, 2987c478bd9Sstevel@tonic-gate char **prop_data); 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate /* 3027c478bd9Sstevel@tonic-gate * Interfaces for private data 3037c478bd9Sstevel@tonic-gate */ 3047c478bd9Sstevel@tonic-gate extern di_node_t di_init_driver(const char *drv_name, uint_t flag); 3057c478bd9Sstevel@tonic-gate extern di_node_t di_init_impl(const char *phys_path, uint_t flag, 3067c478bd9Sstevel@tonic-gate struct di_priv_data *priv_data); 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate /* 3097c478bd9Sstevel@tonic-gate * Prtconf needs to know property lists, raw prop_data, and private data 3107c478bd9Sstevel@tonic-gate */ 3117c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_drv_next(di_node_t node, di_prop_t prop); 3127c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_sys_next(di_node_t node, di_prop_t prop); 3137c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_global_next(di_node_t node, di_prop_t prop); 3147c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_hw_next(di_node_t node, di_prop_t prop); 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate extern int di_prop_rawdata(di_prop_t prop, uchar_t **prop_data); 3177c478bd9Sstevel@tonic-gate extern void *di_parent_private_data(di_node_t node); 3187c478bd9Sstevel@tonic-gate extern void *di_driver_private_data(di_node_t node); 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate /* 3217c478bd9Sstevel@tonic-gate * Types of links for devlink lookup 3227c478bd9Sstevel@tonic-gate */ 3237c478bd9Sstevel@tonic-gate #define DI_PRIMARY_LINK 0x01 3247c478bd9Sstevel@tonic-gate #define DI_SECONDARY_LINK 0x02 3257c478bd9Sstevel@tonic-gate #define DI_LINK_TYPES 0x03 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate /* 3287c478bd9Sstevel@tonic-gate * Flag for di_devlink_init() 3297c478bd9Sstevel@tonic-gate */ 3307c478bd9Sstevel@tonic-gate #define DI_MAKE_LINK 0x01 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate /* 3337c478bd9Sstevel@tonic-gate * Flag for di_devlink_close() 3347c478bd9Sstevel@tonic-gate */ 3357c478bd9Sstevel@tonic-gate #define DI_LINK_ERROR 0x01 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate /* 3387c478bd9Sstevel@tonic-gate * For devfsadm synchronous link creation interfaces 3397c478bd9Sstevel@tonic-gate */ 3407c478bd9Sstevel@tonic-gate #define DEVFSADM_SYNCH_DOOR ".devfsadm_synch_door" 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate /* 3437c478bd9Sstevel@tonic-gate * devlink create argument 3447c478bd9Sstevel@tonic-gate */ 3457c478bd9Sstevel@tonic-gate struct dca_off { 3467c478bd9Sstevel@tonic-gate uint32_t dca_root; 3477c478bd9Sstevel@tonic-gate uint32_t dca_minor; 3487c478bd9Sstevel@tonic-gate uint32_t dca_driver; 3497c478bd9Sstevel@tonic-gate int dca_error; 3507c478bd9Sstevel@tonic-gate int dca_flags; 3517c478bd9Sstevel@tonic-gate char dca_name[PATH_MAX+MAXNAMELEN]; 3527c478bd9Sstevel@tonic-gate }; 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_init(const char *name, uint_t flags); 3557c478bd9Sstevel@tonic-gate extern int di_devlink_walk(di_devlink_handle_t hdl, const char *re, 3567c478bd9Sstevel@tonic-gate const char *minor_path, uint_t flags, void *arg, 3577c478bd9Sstevel@tonic-gate int (*devlink_callback)(di_devlink_t, void *)); 3587c478bd9Sstevel@tonic-gate extern const char *di_devlink_path(di_devlink_t devlink); 3597c478bd9Sstevel@tonic-gate extern const char *di_devlink_content(di_devlink_t devlink); 3607c478bd9Sstevel@tonic-gate extern int di_devlink_type(di_devlink_t devlink); 3617c478bd9Sstevel@tonic-gate extern di_devlink_t di_devlink_dup(di_devlink_t devlink); 3627c478bd9Sstevel@tonic-gate extern int di_devlink_free(di_devlink_t devlink); 3637c478bd9Sstevel@tonic-gate extern int di_devlink_fini(di_devlink_handle_t *hdlp); 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_open(const char *root_dir, uint_t flags); 3667c478bd9Sstevel@tonic-gate extern int di_devlink_close(di_devlink_handle_t *pp, int flag); 3677c478bd9Sstevel@tonic-gate extern int di_devlink_rm_link(di_devlink_handle_t hdp, const char *link); 3687c478bd9Sstevel@tonic-gate extern int di_devlink_add_link(di_devlink_handle_t hdp, const char *link, 3697c478bd9Sstevel@tonic-gate const char *content, int flags); 3707c478bd9Sstevel@tonic-gate extern int di_devlink_update(di_devlink_handle_t hdp); 3717c478bd9Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_init_root(const char *root, 3727c478bd9Sstevel@tonic-gate const char *name, uint_t flags); 3737c478bd9Sstevel@tonic-gate extern int di_devlink_cache_walk(di_devlink_handle_t hdp, const char *re, 3747c478bd9Sstevel@tonic-gate const char *path, uint_t flags, void *arg, 3757c478bd9Sstevel@tonic-gate int (*devlink_callback)(di_devlink_t, void *)); 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate /* 3787c478bd9Sstevel@tonic-gate * Private interfaces for /etc/logindevperm 3797c478bd9Sstevel@tonic-gate */ 3807c478bd9Sstevel@tonic-gate extern int di_devperm_login(const char *, uid_t, gid_t, void (*)(char *)); 3817c478bd9Sstevel@tonic-gate extern int di_devperm_logout(const char *); 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate /* 3847c478bd9Sstevel@tonic-gate * Private interface for looking up a node in a snapshot 3857c478bd9Sstevel@tonic-gate */ 3867c478bd9Sstevel@tonic-gate extern di_node_t di_lookup_node(di_node_t root, char *path); 3877c478bd9Sstevel@tonic-gate 3883c4226f9Spjha 3893c4226f9Spjha /* 3903c4226f9Spjha * Private hotplug interfaces to be used between cfgadm pci plugin and 3913c4226f9Spjha * devfsadm link generator. 3923c4226f9Spjha */ 3933c4226f9Spjha extern char *di_dli_name(char *); 3943c4226f9Spjha extern int di_dli_openr(char *); 3953c4226f9Spjha extern int di_dli_openw(char *); 3963c4226f9Spjha extern void di_dli_close(int); 3973c4226f9Spjha 398*facf4a8dSllai /* 399*facf4a8dSllai * Private interface for parsing devname binding info 400*facf4a8dSllai */ 401*facf4a8dSllai extern void di_devname_print_mapinfo(nvlist_t *); 402*facf4a8dSllai extern int di_devname_get_mapinfo(char *, nvlist_t **); 403*facf4a8dSllai extern int di_devname_get_mapent(char *, char *, nvlist_t **); 404*facf4a8dSllai extern int di_devname_action_on_key(nvlist_t *, uint8_t, char *, void *); 405*facf4a8dSllai 406*facf4a8dSllai /* 407*facf4a8dSllai * finddev - alternate readdir to discover only /dev persisted device names 408*facf4a8dSllai */ 409*facf4a8dSllai typedef struct __finddevhdl *finddevhdl_t; 410*facf4a8dSllai 411*facf4a8dSllai extern int device_exists(const char *); 412*facf4a8dSllai extern int finddev_readdir(const char *, finddevhdl_t *); 413*facf4a8dSllai extern void finddev_close(finddevhdl_t); 414*facf4a8dSllai extern const char *finddev_next(finddevhdl_t); 415*facf4a8dSllai 416*facf4a8dSllai /* For interfaces implementing search either by readdir or finddev */ 417*facf4a8dSllai #define FLAG_USE_READDIR 0 418*facf4a8dSllai #define FLAG_USE_FINDDEV 1 419*facf4a8dSllai 420*facf4a8dSllai 421*facf4a8dSllai /* 422*facf4a8dSllai * Private interfaces for non-global /dev profile 423*facf4a8dSllai */ 424*facf4a8dSllai typedef struct __di_prof *di_prof_t; 425*facf4a8dSllai 426*facf4a8dSllai extern int di_prof_init(const char *mountpt, di_prof_t *); 427*facf4a8dSllai extern void di_prof_fini(di_prof_t); 428*facf4a8dSllai extern int di_prof_commit(di_prof_t); 429*facf4a8dSllai extern int di_prof_add_dev(di_prof_t, const char *); 430*facf4a8dSllai extern int di_prof_add_exclude(di_prof_t, const char *); 431*facf4a8dSllai extern int di_prof_add_symlink(di_prof_t, const char *, const char *); 432*facf4a8dSllai extern int di_prof_add_map(di_prof_t, const char *, const char *); 433*facf4a8dSllai 4347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4357c478bd9Sstevel@tonic-gate } 4367c478bd9Sstevel@tonic-gate #endif 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate #endif /* _LIBDEVINFO_H */ 439