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 /* 22*94c894bbSVikram Hegde * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _LIBDEVINFO_H 267c478bd9Sstevel@tonic-gate #define _LIBDEVINFO_H 277c478bd9Sstevel@tonic-gate 28facf4a8dSllai1 #ifdef __cplusplus 29facf4a8dSllai1 extern "C" { 30facf4a8dSllai1 #endif 31facf4a8dSllai1 327c478bd9Sstevel@tonic-gate #include <errno.h> 33facf4a8dSllai1 #include <libnvpair.h> 347c478bd9Sstevel@tonic-gate #include <sys/param.h> 357c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 367c478bd9Sstevel@tonic-gate #include <sys/sunmdi.h> 377c478bd9Sstevel@tonic-gate #include <sys/openpromio.h> 387c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 397c478bd9Sstevel@tonic-gate #include <sys/devinfo_impl.h> 407c478bd9Sstevel@tonic-gate #include <limits.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * flags for di_walk_node 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate #define DI_WALK_CLDFIRST 0 467c478bd9Sstevel@tonic-gate #define DI_WALK_SIBFIRST 1 477c478bd9Sstevel@tonic-gate #define DI_WALK_LINKGEN 2 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define DI_WALK_MASK 0xf 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * flags for di_walk_link 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate #define DI_LINK_SRC 1 557c478bd9Sstevel@tonic-gate #define DI_LINK_TGT 2 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* 587c478bd9Sstevel@tonic-gate * return code for node_callback 597c478bd9Sstevel@tonic-gate */ 607c478bd9Sstevel@tonic-gate #define DI_WALK_CONTINUE 0 617c478bd9Sstevel@tonic-gate #define DI_WALK_PRUNESIB -1 627c478bd9Sstevel@tonic-gate #define DI_WALK_PRUNECHILD -2 637c478bd9Sstevel@tonic-gate #define DI_WALK_TERMINATE -3 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * flags for di_walk_minor 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate #define DI_CHECK_ALIAS 0x10 697c478bd9Sstevel@tonic-gate #define DI_CHECK_INTERNAL_PATH 0x20 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate #define DI_CHECK_MASK 0xf0 727c478bd9Sstevel@tonic-gate 7326947304SEvan Yan /* 7426947304SEvan Yan * flags for di_walk_hp 7526947304SEvan Yan */ 7626947304SEvan Yan #define DI_HP_CONNECTOR 0x1 7726947304SEvan Yan #define DI_HP_PORT 0x2 7826947304SEvan Yan 797c478bd9Sstevel@tonic-gate /* nodeid types */ 807c478bd9Sstevel@tonic-gate #define DI_PSEUDO_NODEID -1 817c478bd9Sstevel@tonic-gate #define DI_SID_NODEID -2 827c478bd9Sstevel@tonic-gate #define DI_PROM_NODEID -3 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* node & device states */ 857c478bd9Sstevel@tonic-gate #define DI_DRIVER_DETACHED 0x8000 867c478bd9Sstevel@tonic-gate #define DI_DEVICE_OFFLINE 0x1 877c478bd9Sstevel@tonic-gate #define DI_DEVICE_DOWN 0x2 8825c6ff4bSstephh #define DI_DEVICE_DEGRADED 0x4 894c06356bSdh142964 #define DI_DEVICE_REMOVED 0x8 907c478bd9Sstevel@tonic-gate #define DI_BUS_QUIESCED 0x100 917c478bd9Sstevel@tonic-gate #define DI_BUS_DOWN 0x200 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* property types */ 947c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_BOOLEAN 0 957c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_INT 1 967c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_STRING 2 977c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_BYTE 3 987c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_UNKNOWN 4 997c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_UNDEF_IT 5 1007c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_INT64 6 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* private macro for checking if a prop type is valid */ 1037c478bd9Sstevel@tonic-gate #define DI_PROP_TYPE_VALID(type) \ 1047c478bd9Sstevel@tonic-gate ((((type) >= DI_PROP_TYPE_INT) && ((type) <= DI_PROP_TYPE_BYTE)) || \ 1057c478bd9Sstevel@tonic-gate ((type) == DI_PROP_TYPE_INT64)) 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* opaque handles */ 108602ca9eaScth typedef struct di_node *di_node_t; /* node */ 109602ca9eaScth typedef struct di_minor *di_minor_t; /* minor_node */ 110602ca9eaScth typedef struct di_path *di_path_t; /* path_node */ 111602ca9eaScth typedef struct di_link *di_link_t; /* link */ 112602ca9eaScth typedef struct di_lnode *di_lnode_t; /* endpoint */ 113602ca9eaScth typedef struct di_devlink *di_devlink_t; /* devlink */ 11426947304SEvan Yan typedef struct di_hp *di_hp_t; /* hotplug */ 1157c478bd9Sstevel@tonic-gate 116602ca9eaScth typedef struct di_prop *di_prop_t; /* node property */ 117602ca9eaScth typedef struct di_path_prop *di_path_prop_t; /* path property */ 118602ca9eaScth typedef struct di_prom_prop *di_prom_prop_t; /* prom property */ 1197c478bd9Sstevel@tonic-gate 120602ca9eaScth typedef struct di_prom_handle *di_prom_handle_t; /* prom snapshot */ 1217c478bd9Sstevel@tonic-gate typedef struct di_devlink_handle *di_devlink_handle_t; /* devlink snapshot */ 122602ca9eaScth 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * Null handles to make handles really opaque 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate #define DI_NODE_NIL NULL 128602ca9eaScth #define DI_MINOR_NIL NULL 129602ca9eaScth #define DI_PATH_NIL NULL 1307c478bd9Sstevel@tonic-gate #define DI_LINK_NIL NULL 1317c478bd9Sstevel@tonic-gate #define DI_LNODE_NIL NULL 1327c478bd9Sstevel@tonic-gate #define DI_PROP_NIL NULL 1337c478bd9Sstevel@tonic-gate #define DI_PROM_PROP_NIL NULL 1347c478bd9Sstevel@tonic-gate #define DI_PROM_HANDLE_NIL NULL 13526947304SEvan Yan #define DI_HP_NIL NULL 1367c478bd9Sstevel@tonic-gate 1373ebafc43Sjveta /* 1383ebafc43Sjveta * IEEE 1275 properties and other standardized property names 1393ebafc43Sjveta */ 1403ebafc43Sjveta #define DI_PROP_FIRST_CHAS "first-in-chassis" 1413ebafc43Sjveta #define DI_PROP_SLOT_NAMES "slot-names" 1423ebafc43Sjveta #define DI_PROP_PHYS_SLOT "physical-slot#" 1433ebafc43Sjveta #define DI_PROP_DEV_TYPE "device_type" 1443ebafc43Sjveta #define DI_PROP_BUS_RANGE "bus-range" 1453ebafc43Sjveta #define DI_PROP_SERID "serialid#" 1463ebafc43Sjveta #define DI_PROP_REG "reg" 1473ebafc43Sjveta #define DI_PROP_AP_NAMES "ap-names" 1483ebafc43Sjveta 1497c478bd9Sstevel@tonic-gate /* Interface Prototypes */ 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* 1527c478bd9Sstevel@tonic-gate * Snapshot initialization and cleanup 1537c478bd9Sstevel@tonic-gate */ 1547c478bd9Sstevel@tonic-gate extern di_node_t di_init(const char *phys_path, uint_t flag); 1557c478bd9Sstevel@tonic-gate extern void di_fini(di_node_t root); 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate /* 158602ca9eaScth * node: traversal, data access, and parameters 1597c478bd9Sstevel@tonic-gate */ 1607c478bd9Sstevel@tonic-gate extern int di_walk_node(di_node_t root, uint_t flag, void *arg, 1617c478bd9Sstevel@tonic-gate int (*node_callback)(di_node_t node, void *arg)); 1627c478bd9Sstevel@tonic-gate 163602ca9eaScth extern di_node_t di_drv_first_node(const char *drv_name, di_node_t root); 164602ca9eaScth extern di_node_t di_drv_next_node(di_node_t node); 1657c478bd9Sstevel@tonic-gate 166602ca9eaScth extern di_node_t di_parent_node(di_node_t node); 167602ca9eaScth extern di_node_t di_sibling_node(di_node_t node); 168602ca9eaScth extern di_node_t di_child_node(di_node_t node); 169602ca9eaScth 1707c478bd9Sstevel@tonic-gate extern char *di_node_name(di_node_t node); 1717c478bd9Sstevel@tonic-gate extern char *di_bus_addr(di_node_t node); 1727c478bd9Sstevel@tonic-gate extern char *di_binding_name(di_node_t node); 1737c478bd9Sstevel@tonic-gate extern int di_compatible_names(di_node_t, char **names); 1747c478bd9Sstevel@tonic-gate extern int di_instance(di_node_t node); 1757c478bd9Sstevel@tonic-gate extern int di_nodeid(di_node_t node); 1767c478bd9Sstevel@tonic-gate extern int di_driver_major(di_node_t node); 1777c478bd9Sstevel@tonic-gate extern uint_t di_state(di_node_t node); 1787c478bd9Sstevel@tonic-gate extern ddi_node_state_t di_node_state(di_node_t node); 1797c478bd9Sstevel@tonic-gate extern ddi_devid_t di_devid(di_node_t node); 1807c478bd9Sstevel@tonic-gate extern char *di_driver_name(di_node_t node); 1817c478bd9Sstevel@tonic-gate extern uint_t di_driver_ops(di_node_t node); 1827c478bd9Sstevel@tonic-gate 183602ca9eaScth extern void di_node_private_set(di_node_t node, void *data); 184602ca9eaScth extern void *di_node_private_get(di_node_t node); 185602ca9eaScth 1867c478bd9Sstevel@tonic-gate extern char *di_devfs_path(di_node_t node); 1877c478bd9Sstevel@tonic-gate extern char *di_devfs_minor_path(di_minor_t minor); 1887c478bd9Sstevel@tonic-gate extern void di_devfs_path_free(char *path_buf); 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate /* 191602ca9eaScth * path_node: traversal, data access, and parameters 1927c478bd9Sstevel@tonic-gate */ 193602ca9eaScth extern di_path_t di_path_phci_next_path(di_node_t node, di_path_t); 194602ca9eaScth extern di_path_t di_path_client_next_path(di_node_t node, di_path_t); 1957c478bd9Sstevel@tonic-gate 196602ca9eaScth extern di_node_t di_path_phci_node(di_path_t path); 197602ca9eaScth extern di_node_t di_path_client_node(di_path_t path); 1987c478bd9Sstevel@tonic-gate 199602ca9eaScth extern char *di_path_node_name(di_path_t path); 200602ca9eaScth extern char *di_path_bus_addr(di_path_t path); 201602ca9eaScth extern int di_path_instance(di_path_t path); 202602ca9eaScth extern di_path_state_t di_path_state(di_path_t path); 2034c06356bSdh142964 extern uint_t di_path_flags(di_path_t path); 204602ca9eaScth 205602ca9eaScth extern char *di_path_devfs_path(di_path_t path); 206602ca9eaScth extern char *di_path_client_devfs_path(di_path_t path); 207602ca9eaScth 208602ca9eaScth extern void di_path_private_set(di_path_t path, void *data); 209602ca9eaScth extern void *di_path_private_get(di_path_t path); 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate /* 212602ca9eaScth * minor_node: traversal, data access, and parameters 2137c478bd9Sstevel@tonic-gate */ 214602ca9eaScth extern int di_walk_minor(di_node_t root, const char *minortype, 215602ca9eaScth uint_t flag, void *arg, 216602ca9eaScth int (*minor_callback)(di_node_t node, 217602ca9eaScth di_minor_t minor, void *arg)); 2187c478bd9Sstevel@tonic-gate extern di_minor_t di_minor_next(di_node_t node, di_minor_t minor); 219602ca9eaScth 2207c478bd9Sstevel@tonic-gate extern di_node_t di_minor_devinfo(di_minor_t minor); 2217c478bd9Sstevel@tonic-gate extern ddi_minor_type di_minor_type(di_minor_t minor); 2227c478bd9Sstevel@tonic-gate extern char *di_minor_name(di_minor_t minor); 2237c478bd9Sstevel@tonic-gate extern dev_t di_minor_devt(di_minor_t minor); 2247c478bd9Sstevel@tonic-gate extern int di_minor_spectype(di_minor_t minor); 2257c478bd9Sstevel@tonic-gate extern char *di_minor_nodetype(di_minor_t node); 2267c478bd9Sstevel@tonic-gate 227602ca9eaScth extern void di_minor_private_set(di_minor_t minor, void *data); 228602ca9eaScth extern void *di_minor_private_get(di_minor_t minor); 229602ca9eaScth 2307c478bd9Sstevel@tonic-gate /* 231602ca9eaScth * node: property access 2327c478bd9Sstevel@tonic-gate */ 2337c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_next(di_node_t node, di_prop_t prop); 234602ca9eaScth 2357c478bd9Sstevel@tonic-gate extern char *di_prop_name(di_prop_t prop); 2367c478bd9Sstevel@tonic-gate extern int di_prop_type(di_prop_t prop); 237602ca9eaScth extern dev_t di_prop_devt(di_prop_t prop); 238602ca9eaScth 2397c478bd9Sstevel@tonic-gate extern int di_prop_ints(di_prop_t prop, int **prop_data); 2407c478bd9Sstevel@tonic-gate extern int di_prop_int64(di_prop_t prop, int64_t **prop_data); 2417c478bd9Sstevel@tonic-gate extern int di_prop_strings(di_prop_t prop, char **prop_data); 2427c478bd9Sstevel@tonic-gate extern int di_prop_bytes(di_prop_t prop, uchar_t **prop_data); 243602ca9eaScth 244602ca9eaScth extern int di_prop_lookup_bytes(dev_t dev, di_node_t node, 245602ca9eaScth const char *prop_name, uchar_t **prop_data); 2467c478bd9Sstevel@tonic-gate extern int di_prop_lookup_ints(dev_t dev, di_node_t node, 2477c478bd9Sstevel@tonic-gate const char *prop_name, int **prop_data); 2487c478bd9Sstevel@tonic-gate extern int di_prop_lookup_int64(dev_t dev, di_node_t node, 2497c478bd9Sstevel@tonic-gate const char *prop_name, int64_t **prop_data); 2507c478bd9Sstevel@tonic-gate extern int di_prop_lookup_strings(dev_t dev, di_node_t node, 2517c478bd9Sstevel@tonic-gate const char *prop_name, char **prop_data); 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate /* 254602ca9eaScth * prom_node: property access 2557c478bd9Sstevel@tonic-gate */ 2567c478bd9Sstevel@tonic-gate extern di_prom_handle_t di_prom_init(void); 2577c478bd9Sstevel@tonic-gate extern void di_prom_fini(di_prom_handle_t ph); 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate extern di_prom_prop_t di_prom_prop_next(di_prom_handle_t ph, di_node_t node, 2607c478bd9Sstevel@tonic-gate di_prom_prop_t prom_prop); 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate extern char *di_prom_prop_name(di_prom_prop_t prom_prop); 263602ca9eaScth extern int di_prom_prop_data(di_prom_prop_t prop, 264602ca9eaScth uchar_t **prom_prop_data); 2657c478bd9Sstevel@tonic-gate 266602ca9eaScth extern int di_prom_prop_lookup_ints(di_prom_handle_t prom, 267602ca9eaScth di_node_t node, const char *prom_prop_name, 268602ca9eaScth int **prom_prop_data); 269602ca9eaScth extern int di_prom_prop_lookup_strings(di_prom_handle_t prom, 270602ca9eaScth di_node_t node, const char *prom_prop_name, 271602ca9eaScth char **prom_prop_data); 272602ca9eaScth extern int di_prom_prop_lookup_bytes(di_prom_handle_t prom, 273602ca9eaScth di_node_t node, const char *prom_prop_name, 274602ca9eaScth uchar_t **prom_prop_data); 275602ca9eaScth 276602ca9eaScth /* 277602ca9eaScth * path_node: property access 278602ca9eaScth */ 279602ca9eaScth extern di_path_prop_t di_path_prop_next(di_path_t path, di_path_prop_t prop); 280602ca9eaScth 281602ca9eaScth extern char *di_path_prop_name(di_path_prop_t prop); 282602ca9eaScth extern int di_path_prop_type(di_path_prop_t prop); 283602ca9eaScth extern int di_path_prop_len(di_path_prop_t prop); 284602ca9eaScth 285602ca9eaScth extern int di_path_prop_bytes(di_path_prop_t prop, 286602ca9eaScth uchar_t **prop_data); 287602ca9eaScth extern int di_path_prop_ints(di_path_prop_t prop, 288602ca9eaScth int **prop_data); 289602ca9eaScth extern int di_path_prop_int64s(di_path_prop_t prop, 290602ca9eaScth int64_t **prop_data); 291602ca9eaScth extern int di_path_prop_strings(di_path_prop_t prop, 292602ca9eaScth char **prop_data); 293602ca9eaScth 294602ca9eaScth extern int di_path_prop_lookup_bytes(di_path_t path, 295602ca9eaScth const char *prop_name, uchar_t **prop_data); 296602ca9eaScth extern int di_path_prop_lookup_ints(di_path_t path, 297602ca9eaScth const char *prop_name, int **prop_data); 298602ca9eaScth extern int di_path_prop_lookup_int64s(di_path_t path, 299602ca9eaScth const char *prop_name, int64_t **prop_data); 300602ca9eaScth extern int di_path_prop_lookup_strings(di_path_t path, 301602ca9eaScth const char *prop_name, char **prop_data); 302602ca9eaScth 303602ca9eaScth /* 304602ca9eaScth * layering link/lnode: traversal, data access, and parameters 305602ca9eaScth */ 306602ca9eaScth extern int di_walk_link(di_node_t root, uint_t flag, 307602ca9eaScth uint_t endpoint, void *arg, 308602ca9eaScth int (*link_callback)(di_link_t link, void *arg)); 309602ca9eaScth extern int di_walk_lnode(di_node_t root, uint_t flag, void *arg, 310602ca9eaScth int (*lnode_callback)(di_lnode_t lnode, void *arg)); 311602ca9eaScth 312602ca9eaScth extern di_link_t di_link_next_by_node(di_node_t node, 313602ca9eaScth di_link_t link, uint_t endpoint); 314602ca9eaScth extern di_link_t di_link_next_by_lnode(di_lnode_t lnode, 315602ca9eaScth di_link_t link, uint_t endpoint); 316602ca9eaScth extern di_lnode_t di_lnode_next(di_node_t node, di_lnode_t lnode); 317602ca9eaScth extern char *di_lnode_name(di_lnode_t lnode); 318602ca9eaScth 319602ca9eaScth extern int di_link_spectype(di_link_t link); 320602ca9eaScth extern di_lnode_t di_link_to_lnode(di_link_t link, uint_t endpoint); 321602ca9eaScth 322602ca9eaScth extern di_node_t di_lnode_devinfo(di_lnode_t lnode); 323602ca9eaScth extern int di_lnode_devt(di_lnode_t lnode, dev_t *devt); 324602ca9eaScth 325602ca9eaScth extern void di_link_private_set(di_link_t link, void *data); 326602ca9eaScth extern void *di_link_private_get(di_link_t link); 327602ca9eaScth extern void di_lnode_private_set(di_lnode_t lnode, void *data); 328602ca9eaScth extern void *di_lnode_private_get(di_lnode_t lnode); 329602ca9eaScth 33026947304SEvan Yan /* 33126947304SEvan Yan * hp_node: traversal, data access, and parameters 33226947304SEvan Yan */ 33326947304SEvan Yan extern int di_walk_hp(di_node_t node, const char *type, 33426947304SEvan Yan uint_t flag, void *arg, 33526947304SEvan Yan int (*hp_callback)(di_node_t node, di_hp_t hp, 33626947304SEvan Yan void *arg)); 33726947304SEvan Yan extern di_hp_t di_hp_next(di_node_t node, di_hp_t hp); 33826947304SEvan Yan 33926947304SEvan Yan extern char *di_hp_name(di_hp_t hp); 34026947304SEvan Yan extern int di_hp_connection(di_hp_t hp); 34126947304SEvan Yan extern int di_hp_depends_on(di_hp_t hp); 34226947304SEvan Yan extern int di_hp_state(di_hp_t hp); 34326947304SEvan Yan extern int di_hp_type(di_hp_t hp); 34426947304SEvan Yan extern char *di_hp_description(di_hp_t hp); 34526947304SEvan Yan extern time_t di_hp_last_change(di_hp_t hp); 34626947304SEvan Yan extern di_node_t di_hp_child(di_hp_t hp); 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate /* 3497c478bd9Sstevel@tonic-gate * Private interfaces 3507c478bd9Sstevel@tonic-gate * 3517c478bd9Sstevel@tonic-gate * The interfaces and structures below are private to this implementation 3527c478bd9Sstevel@tonic-gate * of Solaris and are subject to change at any time without notice. 3537c478bd9Sstevel@tonic-gate * 354602ca9eaScth * Applications and drivers using these interfaces may fail 3557c478bd9Sstevel@tonic-gate * to run on future releases. 3567c478bd9Sstevel@tonic-gate */ 3573ebafc43Sjveta extern di_prop_t di_prop_find(dev_t match_dev, di_node_t node, 3583ebafc43Sjveta const char *name); 359602ca9eaScth extern int di_devfs_path_match(const char *dp1, const char *dp2); 360602ca9eaScth 361602ca9eaScth extern di_node_t di_vhci_first_node(di_node_t root); 362602ca9eaScth extern di_node_t di_vhci_next_node(di_node_t node); 363602ca9eaScth extern di_node_t di_phci_first_node(di_node_t vhci_node); 364602ca9eaScth extern di_node_t di_phci_next_node(di_node_t node); 3653ebafc43Sjveta 3663ebafc43Sjveta /* 3673ebafc43Sjveta * Interfaces for handling IEEE 1275 and other standardized properties 3683ebafc43Sjveta */ 3693ebafc43Sjveta 3703ebafc43Sjveta /* structure for a single slot */ 3713ebafc43Sjveta typedef struct di_slot_name { 3723ebafc43Sjveta int num; /* corresponding pci device number */ 3733ebafc43Sjveta char *name; 3743ebafc43Sjveta } di_slot_name_t; 3753ebafc43Sjveta 3763ebafc43Sjveta extern void di_slot_names_free(int count, di_slot_name_t *slot_names); 3773ebafc43Sjveta extern int di_slot_names_decode(uchar_t *rawdata, int rawlen, 3783ebafc43Sjveta di_slot_name_t **prop_data); 3793ebafc43Sjveta extern int di_prop_slot_names(di_prop_t prop, di_slot_name_t **prop_data); 3803ebafc43Sjveta extern int di_prom_prop_slot_names(di_prom_prop_t prom_prop, 3813ebafc43Sjveta di_slot_name_t **prop_data); 3823ebafc43Sjveta extern int di_prop_lookup_slot_names(dev_t dev, di_node_t node, 3833ebafc43Sjveta di_slot_name_t **prop_data); 3843ebafc43Sjveta extern int di_prom_prop_lookup_slot_names(di_prom_handle_t ph, di_node_t node, 3853ebafc43Sjveta di_slot_name_t **prop_data); 3863ebafc43Sjveta 3877c478bd9Sstevel@tonic-gate /* 388602ca9eaScth * XXX Remove the private di_path_(addr,next,next_phci,next_client) interfaces 389602ca9eaScth * below after NWS consolidation switches to using di_path_bus_addr, 390602ca9eaScth * di_path_phci_next_path, and di_path_client_next_path per CR6638521. 3917c478bd9Sstevel@tonic-gate */ 392602ca9eaScth extern char *di_path_addr(di_path_t path, char *buf); 3937c478bd9Sstevel@tonic-gate extern di_path_t di_path_next(di_node_t node, di_path_t path); 3947c478bd9Sstevel@tonic-gate extern di_path_t di_path_next_phci(di_node_t node, di_path_t path); 3957c478bd9Sstevel@tonic-gate extern di_path_t di_path_next_client(di_node_t node, di_path_t path); 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate /* 3987c478bd9Sstevel@tonic-gate * Interfaces for private data 3997c478bd9Sstevel@tonic-gate */ 4007c478bd9Sstevel@tonic-gate extern di_node_t di_init_driver(const char *drv_name, uint_t flag); 4017c478bd9Sstevel@tonic-gate extern di_node_t di_init_impl(const char *phys_path, uint_t flag, 4027c478bd9Sstevel@tonic-gate struct di_priv_data *priv_data); 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate /* 4057c478bd9Sstevel@tonic-gate * Prtconf needs to know property lists, raw prop_data, and private data 4067c478bd9Sstevel@tonic-gate */ 4077c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_drv_next(di_node_t node, di_prop_t prop); 4087c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_sys_next(di_node_t node, di_prop_t prop); 4097c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_global_next(di_node_t node, di_prop_t prop); 4107c478bd9Sstevel@tonic-gate extern di_prop_t di_prop_hw_next(di_node_t node, di_prop_t prop); 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate extern int di_prop_rawdata(di_prop_t prop, uchar_t **prop_data); 4137c478bd9Sstevel@tonic-gate extern void *di_parent_private_data(di_node_t node); 4147c478bd9Sstevel@tonic-gate extern void *di_driver_private_data(di_node_t node); 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate /* 41725e8c5aaSvikram * The value of the dip's devi_flags field 41825e8c5aaSvikram */ 41925e8c5aaSvikram uint_t di_flags(di_node_t node); 42025e8c5aaSvikram 42125e8c5aaSvikram /* 4227c478bd9Sstevel@tonic-gate * Types of links for devlink lookup 4237c478bd9Sstevel@tonic-gate */ 4247c478bd9Sstevel@tonic-gate #define DI_PRIMARY_LINK 0x01 4257c478bd9Sstevel@tonic-gate #define DI_SECONDARY_LINK 0x02 4267c478bd9Sstevel@tonic-gate #define DI_LINK_TYPES 0x03 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate /* 4297c478bd9Sstevel@tonic-gate * Flag for di_devlink_init() 4307c478bd9Sstevel@tonic-gate */ 4317c478bd9Sstevel@tonic-gate #define DI_MAKE_LINK 0x01 4327c478bd9Sstevel@tonic-gate 4337c478bd9Sstevel@tonic-gate /* 4347c478bd9Sstevel@tonic-gate * Flag for di_devlink_close() 4357c478bd9Sstevel@tonic-gate */ 4367c478bd9Sstevel@tonic-gate #define DI_LINK_ERROR 0x01 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate /* 4397c478bd9Sstevel@tonic-gate * For devfsadm synchronous link creation interfaces 4407c478bd9Sstevel@tonic-gate */ 4417c478bd9Sstevel@tonic-gate #define DEVFSADM_SYNCH_DOOR ".devfsadm_synch_door" 4427c478bd9Sstevel@tonic-gate 4437c478bd9Sstevel@tonic-gate /* 4447c478bd9Sstevel@tonic-gate * devlink create argument 4457c478bd9Sstevel@tonic-gate */ 4467c478bd9Sstevel@tonic-gate struct dca_off { 4477c478bd9Sstevel@tonic-gate uint32_t dca_root; 4487c478bd9Sstevel@tonic-gate uint32_t dca_minor; 4497c478bd9Sstevel@tonic-gate uint32_t dca_driver; 4507c478bd9Sstevel@tonic-gate int dca_error; 4517c478bd9Sstevel@tonic-gate int dca_flags; 4527c478bd9Sstevel@tonic-gate char dca_name[PATH_MAX+MAXNAMELEN]; 4537c478bd9Sstevel@tonic-gate }; 4547c478bd9Sstevel@tonic-gate 4557c478bd9Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_init(const char *name, uint_t flags); 4567c478bd9Sstevel@tonic-gate extern int di_devlink_walk(di_devlink_handle_t hdl, const char *re, 4577c478bd9Sstevel@tonic-gate const char *minor_path, uint_t flags, void *arg, 4587c478bd9Sstevel@tonic-gate int (*devlink_callback)(di_devlink_t, void *)); 4597c478bd9Sstevel@tonic-gate extern const char *di_devlink_path(di_devlink_t devlink); 4607c478bd9Sstevel@tonic-gate extern const char *di_devlink_content(di_devlink_t devlink); 4617c478bd9Sstevel@tonic-gate extern int di_devlink_type(di_devlink_t devlink); 4627c478bd9Sstevel@tonic-gate extern di_devlink_t di_devlink_dup(di_devlink_t devlink); 4637c478bd9Sstevel@tonic-gate extern int di_devlink_free(di_devlink_t devlink); 4647c478bd9Sstevel@tonic-gate extern int di_devlink_fini(di_devlink_handle_t *hdlp); 4657c478bd9Sstevel@tonic-gate 4667c478bd9Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_open(const char *root_dir, uint_t flags); 4677c478bd9Sstevel@tonic-gate extern int di_devlink_close(di_devlink_handle_t *pp, int flag); 4687c478bd9Sstevel@tonic-gate extern int di_devlink_rm_link(di_devlink_handle_t hdp, const char *link); 4697c478bd9Sstevel@tonic-gate extern int di_devlink_add_link(di_devlink_handle_t hdp, const char *link, 4707c478bd9Sstevel@tonic-gate const char *content, int flags); 4717c478bd9Sstevel@tonic-gate extern int di_devlink_update(di_devlink_handle_t hdp); 4727c478bd9Sstevel@tonic-gate extern di_devlink_handle_t di_devlink_init_root(const char *root, 4737c478bd9Sstevel@tonic-gate const char *name, uint_t flags); 4747c478bd9Sstevel@tonic-gate extern int di_devlink_cache_walk(di_devlink_handle_t hdp, const char *re, 4757c478bd9Sstevel@tonic-gate const char *path, uint_t flags, void *arg, 4767c478bd9Sstevel@tonic-gate int (*devlink_callback)(di_devlink_t, void *)); 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate /* 47925e8c5aaSvikram * Private interfaces for I/O retire 48025e8c5aaSvikram */ 48125e8c5aaSvikram typedef struct di_retire { 48225e8c5aaSvikram void *rt_hdl; 48325e8c5aaSvikram void (*rt_abort)(void *hdl, const char *format, ...); 48425e8c5aaSvikram void (*rt_debug)(void *hdl, const char *format, ...); 48525e8c5aaSvikram } di_retire_t; 48625e8c5aaSvikram 48725e8c5aaSvikram extern int di_retire_device(char *path, di_retire_t *dp, int flags); 48825e8c5aaSvikram extern int di_unretire_device(char *path, di_retire_t *dp); 48925e8c5aaSvikram extern uint_t di_retired(di_node_t node); 49025e8c5aaSvikram 49125e8c5aaSvikram /* 4927c478bd9Sstevel@tonic-gate * Private interfaces for /etc/logindevperm 4937c478bd9Sstevel@tonic-gate */ 4947c478bd9Sstevel@tonic-gate extern int di_devperm_login(const char *, uid_t, gid_t, void (*)(char *)); 4957c478bd9Sstevel@tonic-gate extern int di_devperm_logout(const char *); 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate /* 498602ca9eaScth * Private interface for looking up, by path string, a node/path/minor 499602ca9eaScth * in a snapshot. 5007c478bd9Sstevel@tonic-gate */ 501602ca9eaScth extern di_path_t di_lookup_path(di_node_t root, char *path); 5027c478bd9Sstevel@tonic-gate extern di_node_t di_lookup_node(di_node_t root, char *path); 5037c478bd9Sstevel@tonic-gate 5043c4226f9Spjha /* 5053c4226f9Spjha * Private hotplug interfaces to be used between cfgadm pci plugin and 5063c4226f9Spjha * devfsadm link generator. 5073c4226f9Spjha */ 5083c4226f9Spjha extern char *di_dli_name(char *); 5093c4226f9Spjha extern int di_dli_openr(char *); 5103c4226f9Spjha extern int di_dli_openw(char *); 5113c4226f9Spjha extern void di_dli_close(int); 5123c4226f9Spjha 513facf4a8dSllai1 /* 5141aef0e11Sjg * Private interface for parsing path_to_inst binding file 5151aef0e11Sjg */ 5161aef0e11Sjg extern int devfs_parse_binding_file(const char *, 5171aef0e11Sjg int (*)(void *, const char *, int, const char *), void *); 5181aef0e11Sjg extern int devfs_walk_minor_nodes(const char *, 5191aef0e11Sjg int (*)(void *, const char *), void *); 5201aef0e11Sjg 5211aef0e11Sjg /* 522facf4a8dSllai1 * finddev - alternate readdir to discover only /dev persisted device names 523facf4a8dSllai1 */ 524facf4a8dSllai1 typedef struct __finddevhdl *finddevhdl_t; 525facf4a8dSllai1 526facf4a8dSllai1 extern int device_exists(const char *); 527facf4a8dSllai1 extern int finddev_readdir(const char *, finddevhdl_t *); 528e37c6c37Scth extern int finddev_emptydir(const char *); 529facf4a8dSllai1 extern void finddev_close(finddevhdl_t); 530facf4a8dSllai1 extern const char *finddev_next(finddevhdl_t); 531facf4a8dSllai1 532facf4a8dSllai1 533facf4a8dSllai1 /* 534facf4a8dSllai1 * Private interfaces for non-global /dev profile 535facf4a8dSllai1 */ 536facf4a8dSllai1 typedef struct __di_prof *di_prof_t; 537facf4a8dSllai1 538facf4a8dSllai1 extern int di_prof_init(const char *mountpt, di_prof_t *); 539facf4a8dSllai1 extern void di_prof_fini(di_prof_t); 540facf4a8dSllai1 extern int di_prof_commit(di_prof_t); 541facf4a8dSllai1 extern int di_prof_add_dev(di_prof_t, const char *); 542facf4a8dSllai1 extern int di_prof_add_exclude(di_prof_t, const char *); 543facf4a8dSllai1 extern int di_prof_add_symlink(di_prof_t, const char *, const char *); 544facf4a8dSllai1 extern int di_prof_add_map(di_prof_t, const char *, const char *); 545facf4a8dSllai1 546a08731ecScth /* 547a08731ecScth * Private interfaces for <driver><instance><minor> to path conversion. 548a08731ecScth * NOTE: These interfaces do not require or cause attach. The implementation 549a08731ecScth * uses the kernel instance-tree (/etc/path_to_inst) and the di_devlinks 550a08731ecScth * database information. 551a08731ecScth */ 552a08731ecScth typedef struct __di_dim *di_dim_t; 553a08731ecScth 554a08731ecScth extern di_dim_t di_dim_init(); 555a08731ecScth extern void di_dim_fini(di_dim_t); 556a08731ecScth extern char *di_dim_path_devices(di_dim_t, 557a08731ecScth char *drv_name, int instance, char *minor_name); 558a08731ecScth extern char *di_dim_path_dev(di_dim_t, 559a08731ecScth char *drv_name, int instance, char *minor_name); 560a08731ecScth 561*94c894bbSVikram Hegde /* 562*94c894bbSVikram Hegde * Alias related exported interfaces 563*94c894bbSVikram Hegde */ 564*94c894bbSVikram Hegde char *di_alias2curr(di_node_t anynode, char *alias); 565a08731ecScth 5667c478bd9Sstevel@tonic-gate #ifdef __cplusplus 5677c478bd9Sstevel@tonic-gate } 5687c478bd9Sstevel@tonic-gate #endif 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate #endif /* _LIBDEVINFO_H */ 571