xref: /titanic_41/usr/src/cmd/hal/hald/solaris/devinfo.h (revision 42a7bded1b1244af097afdc88654381a3d3879f9)
118c2aff7Sartem /***************************************************************************
218c2aff7Sartem  *
318c2aff7Sartem  * devinfo.h : definitions for libdevinfo-based device enumeration
418c2aff7Sartem  *
5*42a7bdedSjacobs  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
618c2aff7Sartem  * Use is subject to license terms.
718c2aff7Sartem  *
818c2aff7Sartem  * Licensed under the Academic Free License version 2.1
918c2aff7Sartem  *
1018c2aff7Sartem  **************************************************************************/
1118c2aff7Sartem 
1218c2aff7Sartem #pragma ident	"%Z%%M%	%I%	%E% SMI"
1318c2aff7Sartem 
1418c2aff7Sartem #ifndef DEVINFO_H
1518c2aff7Sartem #define DEVINFO_H
1618c2aff7Sartem 
1718c2aff7Sartem #include <glib.h>
1818c2aff7Sartem #include <libdevinfo.h>
1918c2aff7Sartem 
2018c2aff7Sartem #include "../hald.h"
2118c2aff7Sartem #include "../device_info.h"
2218c2aff7Sartem 
2318c2aff7Sartem typedef struct DevinfoDevHandler_s
2418c2aff7Sartem {
2518c2aff7Sartem 	HalDevice *(*add) (HalDevice *parent, di_node_t node, char *devfs_path, char *device_type);
2618c2aff7Sartem 
2718c2aff7Sartem 	/* yet unused */
2818c2aff7Sartem 	void (*remove) (char *devfs_path);
2918c2aff7Sartem 
3018c2aff7Sartem 	void (*hotplug_begin_add) (HalDevice *d, HalDevice *parent, struct DevinfoDevHandler_s *handler, void *end_token);
3118c2aff7Sartem 
3218c2aff7Sartem 	void (*hotplug_begin_remove) (HalDevice *d, struct DevinfoDevHandler_s *handler, void *end_token);
3318c2aff7Sartem 
3418c2aff7Sartem 	void (*probing_done) (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2);
3518c2aff7Sartem 
3618c2aff7Sartem 	const gchar *(*get_prober) (HalDevice *d, int *timeout);
3718c2aff7Sartem } DevinfoDevHandler;
3818c2aff7Sartem 
3918c2aff7Sartem #define PROP_INT(d, node, v, diprop, halprop) \
4018c2aff7Sartem 	if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, diprop, &(v)) > 0) { \
4118c2aff7Sartem 		hal_device_property_set_int (d, halprop, *(v)); \
4218c2aff7Sartem 	}
4318c2aff7Sartem 
4418c2aff7Sartem #define PROP_STR(d, node, v, diprop, halprop) \
4518c2aff7Sartem 	if (di_prop_lookup_strings(DDI_DEV_T_ANY, node, diprop, &(v)) > 0) { \
4618c2aff7Sartem 		hal_device_property_set_string (d, halprop, v); \
4718c2aff7Sartem 	}
4818c2aff7Sartem 
4918c2aff7Sartem #define PROP_BOOL(d, node, v, diprop, halprop) \
5018c2aff7Sartem 	hal_device_property_set_bool (d, halprop, \
5118c2aff7Sartem 	    (di_prop_lookup_ints(DDI_DEV_T_ANY, node, diprop, &(v)) >= 0));
5218c2aff7Sartem 
5318c2aff7Sartem #define	NELEM(a)	(sizeof (a) / sizeof (*(a)))
5418c2aff7Sartem 
5518c2aff7Sartem void devinfo_add (HalDevice *parent, gchar *path);
5618c2aff7Sartem void devinfo_set_default_properties (HalDevice *d, HalDevice *parent, di_node_t node, char *devfs_path);
5718c2aff7Sartem void devinfo_callouts_preprobing_done (HalDevice *d, gpointer userdata1, gpointer userdata2);
5818c2aff7Sartem void devinfo_callouts_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error,
5918c2aff7Sartem 	gpointer userdata1, gpointer userdata2);
6018c2aff7Sartem void devinfo_callouts_add_done (HalDevice *d, gpointer userdata1, gpointer userdata2);
6118c2aff7Sartem void devinfo_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2);
6218c2aff7Sartem void hotplug_event_begin_add_devinfo (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token);
6318c2aff7Sartem void devinfo_remove (gchar *path);
6418c2aff7Sartem void devinfo_remove_branch (gchar *path, HalDevice *d);
6518c2aff7Sartem void hotplug_event_begin_remove_devinfo (HalDevice *d, gchar *devfs_path, void *end_token);
6618c2aff7Sartem void devinfo_hotplug_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler, int action, int front);
6718c2aff7Sartem void devinfo_add_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler);
6818c2aff7Sartem void devinfo_add_enqueue_at_front(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler);
6918c2aff7Sartem void devinfo_remove_enqueue(gchar *devfs_path, DevinfoDevHandler *handler);
7018c2aff7Sartem gboolean devinfo_device_rescan (HalDevice *d);
71*42a7bdedSjacobs char *get_devlink(di_devlink_handle_t devlink_hdl, char *re, char *path);
72*42a7bdedSjacobs 
7318c2aff7Sartem 
7418c2aff7Sartem #endif /* DEVINFO_H */
75