xref: /illumos-gate/usr/src/cmd/hal/hald/solaris/devinfo.h (revision 42a7bded)
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 
1292f38132Sartem #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 
49