xref: /illumos-gate/usr/src/cmd/hal/hald/solaris/devinfo.h (revision 2a8bcb4e)
1 /***************************************************************************
2  *
3  * devinfo.h : definitions for libdevinfo-based device enumeration
4  *
5  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
6  * Use is subject to license terms.
7  *
8  * Licensed under the Academic Free License version 2.1
9  *
10  **************************************************************************/
11 
12 #ifndef DEVINFO_H
13 #define DEVINFO_H
14 
15 #include <glib.h>
16 #include <libdevinfo.h>
17 
18 #include "../hald.h"
19 #include "../device_info.h"
20 
21 typedef struct DevinfoDevHandler_s
22 {
23 	HalDevice *(*add) (HalDevice *parent, di_node_t node, char *devfs_path, char *device_type);
24 
25 	/* yet unused */
26 	void (*remove) (char *devfs_path);
27 
28 	void (*hotplug_begin_add) (HalDevice *d, HalDevice *parent, struct DevinfoDevHandler_s *handler, void *end_token);
29 
30 	void (*hotplug_begin_remove) (HalDevice *d, struct DevinfoDevHandler_s *handler, void *end_token);
31 
32 	void (*probing_done) (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2);
33 
34 	const gchar *(*get_prober) (HalDevice *d, int *timeout);
35 } DevinfoDevHandler;
36 
37 #define PROP_INT(d, node, v, diprop, halprop) \
38 	if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, diprop, &(v)) > 0) { \
39 		hal_device_property_set_int (d, halprop, *(v)); \
40 	}
41 
42 #define PROP_STR(d, node, v, diprop, halprop) \
43 	if (di_prop_lookup_strings(DDI_DEV_T_ANY, node, diprop, &(v)) > 0) { \
44 		hal_device_property_set_string (d, halprop, v); \
45 	}
46 
47 #define PROP_BOOL(d, node, v, diprop, halprop) \
48 	hal_device_property_set_bool (d, halprop, \
49 	    (di_prop_lookup_ints(DDI_DEV_T_ANY, node, diprop, &(v)) >= 0));
50 
51 #define	NELEM(a)	(sizeof (a) / sizeof (*(a)))
52 
53 void devinfo_add (HalDevice *parent, gchar *path);
54 void devinfo_set_default_properties (HalDevice *d, HalDevice *parent, di_node_t node, char *devfs_path);
55 void devinfo_callouts_preprobing_done (HalDevice *d, gpointer userdata1, gpointer userdata2);
56 void devinfo_callouts_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error,
57 	gpointer userdata1, gpointer userdata2);
58 void devinfo_callouts_add_done (HalDevice *d, gpointer userdata1, gpointer userdata2);
59 void devinfo_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2);
60 void hotplug_event_begin_add_devinfo (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token);
61 void devinfo_remove (gchar *path);
62 void devinfo_remove_branch (gchar *path, HalDevice *d);
63 void hotplug_event_begin_remove_devinfo (HalDevice *d, gchar *devfs_path, void *end_token);
64 void devinfo_hotplug_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler, int action, int front);
65 void devinfo_add_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler);
66 void devinfo_add_enqueue_at_front(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler);
67 void devinfo_remove_enqueue(gchar *devfs_path, DevinfoDevHandler *handler);
68 gboolean devinfo_device_rescan (HalDevice *d);
69 char *get_devlink(di_devlink_handle_t devlink_hdl, char *re, char *path);
70 
71 
72 #endif /* DEVINFO_H */
73