xref: /titanic_41/usr/src/cmd/hal/hald/solaris/devinfo.h (revision f127cb91970601c2695eead0ee127f1cac48bb7a)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
13 
14 #ifndef DEVINFO_H
15 #define DEVINFO_H
16 
17 #include <glib.h>
18 #include <libdevinfo.h>
19 
20 #include "../hald.h"
21 #include "../device_info.h"
22 
23 typedef struct DevinfoDevHandler_s
24 {
25 	HalDevice *(*add) (HalDevice *parent, di_node_t node, char *devfs_path, char *device_type);
26 
27 	/* yet unused */
28 	void (*remove) (char *devfs_path);
29 
30 	void (*hotplug_begin_add) (HalDevice *d, HalDevice *parent, struct DevinfoDevHandler_s *handler, void *end_token);
31 
32 	void (*hotplug_begin_remove) (HalDevice *d, struct DevinfoDevHandler_s *handler, void *end_token);
33 
34 	void (*probing_done) (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2);
35 
36 	const gchar *(*get_prober) (HalDevice *d, int *timeout);
37 } DevinfoDevHandler;
38 
39 #define PROP_INT(d, node, v, diprop, halprop) \
40 	if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, diprop, &(v)) > 0) { \
41 		hal_device_property_set_int (d, halprop, *(v)); \
42 	}
43 
44 #define PROP_STR(d, node, v, diprop, halprop) \
45 	if (di_prop_lookup_strings(DDI_DEV_T_ANY, node, diprop, &(v)) > 0) { \
46 		hal_device_property_set_string (d, halprop, v); \
47 	}
48 
49 #define PROP_BOOL(d, node, v, diprop, halprop) \
50 	hal_device_property_set_bool (d, halprop, \
51 	    (di_prop_lookup_ints(DDI_DEV_T_ANY, node, diprop, &(v)) >= 0));
52 
53 #define	NELEM(a)	(sizeof (a) / sizeof (*(a)))
54 
55 void devinfo_add (HalDevice *parent, gchar *path);
56 void devinfo_set_default_properties (HalDevice *d, HalDevice *parent, di_node_t node, char *devfs_path);
57 void devinfo_callouts_preprobing_done (HalDevice *d, gpointer userdata1, gpointer userdata2);
58 void devinfo_callouts_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error,
59 	gpointer userdata1, gpointer userdata2);
60 void devinfo_callouts_add_done (HalDevice *d, gpointer userdata1, gpointer userdata2);
61 void devinfo_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2);
62 void hotplug_event_begin_add_devinfo (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token);
63 void devinfo_remove (gchar *path);
64 void devinfo_remove_branch (gchar *path, HalDevice *d);
65 void hotplug_event_begin_remove_devinfo (HalDevice *d, gchar *devfs_path, void *end_token);
66 void devinfo_hotplug_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler, int action, int front);
67 void devinfo_add_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler);
68 void devinfo_add_enqueue_at_front(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler);
69 void devinfo_remove_enqueue(gchar *devfs_path, DevinfoDevHandler *handler);
70 gboolean devinfo_device_rescan (HalDevice *d);
71 char *get_devlink(di_devlink_handle_t devlink_hdl, char *re, char *path);
72 
73 
74 #endif /* DEVINFO_H */
75