libdevinfo.h revision 3ebafc43f8c876353693c0e5a9e759edd91165b6
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _LIBDEVINFO_H
#define _LIBDEVINFO_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <errno.h>
#include <libnvpair.h>
#include <sys/openpromio.h>
#include <sys/ddi_impldefs.h>
#include <sys/devinfo_impl.h>
#include <limits.h>
/*
* flags for di_walk_node
*/
#define DI_WALK_CLDFIRST 0
#define DI_WALK_SIBFIRST 1
#define DI_WALK_LINKGEN 2
#define DI_WALK_MASK 0xf
/*
* flags for di_walk_link
*/
#define DI_LINK_SRC 1
#define DI_LINK_TGT 2
/*
* return code for node_callback
*/
#define DI_WALK_CONTINUE 0
#define DI_WALK_PRUNESIB -1
#define DI_WALK_PRUNECHILD -2
#define DI_WALK_TERMINATE -3
/*
* flags for di_walk_minor
*/
#define DI_CHECK_ALIAS 0x10
#define DI_CHECK_INTERNAL_PATH 0x20
#define DI_CHECK_MASK 0xf0
/* nodeid types */
#define DI_PSEUDO_NODEID -1
#define DI_SID_NODEID -2
#define DI_PROM_NODEID -3
/* node & device states */
#define DI_DRIVER_DETACHED 0x8000
#define DI_DEVICE_OFFLINE 0x1
#define DI_DEVICE_DOWN 0x2
#define DI_BUS_QUIESCED 0x100
#define DI_BUS_DOWN 0x200
/* property types */
#define DI_PROP_TYPE_BOOLEAN 0
#define DI_PROP_TYPE_INT 1
#define DI_PROP_TYPE_STRING 2
#define DI_PROP_TYPE_BYTE 3
#define DI_PROP_TYPE_UNKNOWN 4
#define DI_PROP_TYPE_UNDEF_IT 5
#define DI_PROP_TYPE_INT64 6
/* private macro for checking if a prop type is valid */
#define DI_PROP_TYPE_VALID(type) \
((type) == DI_PROP_TYPE_INT64))
/* opaque handles */
/*
* Null handles to make handles really opaque
*/
#define DI_NODE_NIL NULL
#define DI_LINK_NIL NULL
#define DI_LNODE_NIL NULL
#define DI_MINOR_NIL NULL
#define DI_PROP_NIL NULL
#define DI_PROM_PROP_NIL NULL
#define DI_PROM_HANDLE_NIL NULL
#define DI_PATH_NIL NULL
/*
* IEEE 1275 properties and other standardized property names
*/
#define DI_PROP_FIRST_CHAS "first-in-chassis"
#define DI_PROP_SLOT_NAMES "slot-names"
#define DI_PROP_PHYS_SLOT "physical-slot#"
#define DI_PROP_DEV_TYPE "device_type"
#define DI_PROP_BUS_RANGE "bus-range"
#define DI_PROP_SERID "serialid#"
#define DI_PROP_REG "reg"
#define DI_PROP_AP_NAMES "ap-names"
/* Interface Prototypes */
/*
* Snapshot initialization and cleanup
*/
/*
* tree traversal
*/
/*
* tree walking assistants
*/
void *arg));
/*
* generic node parameters
*/
extern void di_devfs_path_free(char *path_buf);
/*
* layering data access
*/
/*
* minor data access
*/
/*
* Software property access
*/
/*
* PROM property access
*/
extern di_prom_handle_t di_prom_init(void);
const char *prom_prop_name, int **prom_prop_data);
const char *prom_prop_name, char **prom_prop_data);
/*
* Private interfaces
*
* The interfaces and structures below are private to this implementation
* of Solaris and are subject to change at any time without notice.
*
* Applications and drivers using these interfaces will fail
* to run on future releases.
*/
const char *name);
/*
* Interfaces for handling IEEE 1275 and other standardized properties
*/
/* structure for a single slot */
typedef struct di_slot_name {
int num; /* corresponding pci device number */
char *name;
/*
* Interfaces for accessing I/O multipathing data
*/
/* XXX remove di_path_next() after updating NWS consolidation */
int **prop_data);
char **prop_data);
/*
* Interfaces for private data
*/
struct di_priv_data *priv_data);
/*
* Prtconf needs to know property lists, raw prop_data, and private data
*/
/*
* Types of links for devlink lookup
*/
#define DI_PRIMARY_LINK 0x01
#define DI_SECONDARY_LINK 0x02
#define DI_LINK_TYPES 0x03
/*
* Flag for di_devlink_init()
*/
#define DI_MAKE_LINK 0x01
/*
* Flag for di_devlink_close()
*/
#define DI_LINK_ERROR 0x01
/*
* For devfsadm synchronous link creation interfaces
*/
#define DEVFSADM_SYNCH_DOOR ".devfsadm_synch_door"
/*
* devlink create argument
*/
struct dca_off {
int dca_error;
int dca_flags;
};
int (*devlink_callback)(di_devlink_t, void *));
int (*devlink_callback)(di_devlink_t, void *));
/*
* Private interfaces for /etc/logindevperm
*/
extern int di_devperm_logout(const char *);
/*
* Private interface for looking up a node in a snapshot
*/
/*
* Private hotplug interfaces to be used between cfgadm pci plugin and
* devfsadm link generator.
*/
extern char *di_dli_name(char *);
extern int di_dli_openr(char *);
extern int di_dli_openw(char *);
extern void di_dli_close(int);
/*
* Private interface for parsing devname binding info
*/
extern void di_devname_print_mapinfo(nvlist_t *);
extern int di_devname_get_mapinfo(char *, nvlist_t **);
extern int di_devname_get_mapent(char *, char *, nvlist_t **);
/*
* finddev - alternate readdir to discover only /dev persisted device names
*/
typedef struct __finddevhdl *finddevhdl_t;
extern int device_exists(const char *);
extern int finddev_readdir(const char *, finddevhdl_t *);
extern void finddev_close(finddevhdl_t);
extern const char *finddev_next(finddevhdl_t);
/*
* Private interfaces for non-global /dev profile
*/
extern void di_prof_fini(di_prof_t);
extern int di_prof_commit(di_prof_t);
extern int di_prof_add_dev(di_prof_t, const char *);
extern int di_prof_add_exclude(di_prof_t, const char *);
extern int di_prof_add_symlink(di_prof_t, const char *, const char *);
extern int di_prof_add_map(di_prof_t, const char *, const char *);
/*
* Private interfaces for <driver><instance><minor> to path conversion.
* NOTE: These interfaces do not require or cause attach. The implementation
* uses the kernel instance-tree (/etc/path_to_inst) and the di_devlinks
* database information.
*/
extern di_dim_t di_dim_init();
extern void di_dim_fini(di_dim_t);
extern char *di_dim_path_devices(di_dim_t,
extern char *di_dim_path_dev(di_dim_t,
#ifdef __cplusplus
}
#endif
#endif /* _LIBDEVINFO_H */