Sat May 19 13:25:36 2018 UTC ()
On NetBSD/arm with FDT, the root device is "armfdt0" instead of "mainbus0".
Bump pkg revision.


(jmcneill)
diff -r1.79 -r1.80 pkgsrc/sysutils/hal/Makefile
diff -r1.5 -r1.6 pkgsrc/sysutils/hal/files/hald-netbsd/devinfo.c
diff -r1.1 -r1.2 pkgsrc/sysutils/hal/files/hald-netbsd/devinfo.h
diff -r1.1 -r1.2 pkgsrc/sysutils/hal/files/hald-netbsd/hotplug.c
diff -r1.6 -r1.7 pkgsrc/sysutils/hal/files/hald-netbsd/devinfo_misc.c
diff -r1.4 -r1.5 pkgsrc/sysutils/hal/files/hald-netbsd/drvctl.c
diff -r1.3 -r1.4 pkgsrc/sysutils/hal/files/hald-netbsd/osspec.c

cvs diff -r1.79 -r1.80 pkgsrc/sysutils/hal/Makefile (switch to unified diff)

--- pkgsrc/sysutils/hal/Makefile 2017/10/10 13:51:21 1.79
+++ pkgsrc/sysutils/hal/Makefile 2018/05/19 13:25:36 1.80
@@ -1,130 +1,130 @@ @@ -1,130 +1,130 @@
1# $NetBSD: Makefile,v 1.79 2017/10/10 13:51:21 jperkin Exp $ 1# $NetBSD: Makefile,v 1.80 2018/05/19 13:25:36 jmcneill Exp $
2 2
3DISTNAME= hal-0.5.14 3DISTNAME= hal-0.5.14
4PKGREVISION= 18 4PKGREVISION= 19
5CATEGORIES= sysutils 5CATEGORIES= sysutils
6MASTER_SITES= http://hal.freedesktop.org/releases/ 6MASTER_SITES= http://hal.freedesktop.org/releases/
7EXTRACT_SUFX= .tar.bz2 7EXTRACT_SUFX= .tar.bz2
8 8
9MAINTAINER= pkgsrc-users@NetBSD.org 9MAINTAINER= pkgsrc-users@NetBSD.org
10HOMEPAGE= http://hal.freedesktop.org/ 10HOMEPAGE= http://hal.freedesktop.org/
11COMMENT= FreeDesktop hardware abstraction layer 11COMMENT= FreeDesktop hardware abstraction layer
12LICENSE= gnu-gpl-v2 12LICENSE= gnu-gpl-v2
13 13
14DEPENDS+= pciids-[0-9]*:../../misc/pciids 14DEPENDS+= pciids-[0-9]*:../../misc/pciids
15 15
16BUILD_DEFS+= VARBASE PKG_SYSCONFBASE 16BUILD_DEFS+= VARBASE PKG_SYSCONFBASE
17 17
18GNU_CONFIGURE= YES 18GNU_CONFIGURE= YES
19USE_PKGLOCALEDIR= YES 19USE_PKGLOCALEDIR= YES
20USE_TOOLS+= gmake intltool msgfmt perl pkg-config 20USE_TOOLS+= gmake intltool msgfmt perl pkg-config
21USE_TOOLS+= autoconf automake autoreconf 21USE_TOOLS+= autoconf automake autoreconf
22USE_LIBTOOL= YES 22USE_LIBTOOL= YES
23 23
24MAKE_DIRS+= /media 24MAKE_DIRS+= /media
25MAKE_DIRS+= ${VARBASE}/cache/hald 25MAKE_DIRS+= ${VARBASE}/cache/hald
26SPECIAL_PERMS+= ${VARBASE}/cache/hald ${HAL_USER} ${HAL_GROUP} 0644 26SPECIAL_PERMS+= ${VARBASE}/cache/hald ${HAL_USER} ${HAL_GROUP} 0644
27 27
28EGDIR= ${PREFIX}/share/examples/hal 28EGDIR= ${PREFIX}/share/examples/hal
29 29
30CONF_FILES= ${EGDIR}/hal.conf ${PKG_SYSCONFBASE}/dbus-1/system.d/hal.conf 30CONF_FILES= ${EGDIR}/hal.conf ${PKG_SYSCONFBASE}/dbus-1/system.d/hal.conf
31 31
32CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFBASE} 32CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFBASE}
33CONFIGURE_ARGS+= --localstatedir=${VARBASE} 33CONFIGURE_ARGS+= --localstatedir=${VARBASE}
34CONFIGURE_ARGS+= --with-pci-ids=${PREFIX}/share/pciids 34CONFIGURE_ARGS+= --with-pci-ids=${PREFIX}/share/pciids
35CONFIGURE_ARGS+= --with-usb-ids=${PREFIX}/share/usbids 35CONFIGURE_ARGS+= --with-usb-ids=${PREFIX}/share/usbids
36CONFIGURE_ARGS+= --without-os-type 36CONFIGURE_ARGS+= --without-os-type
37 37
38.include "../../mk/bsd.prefs.mk" 38.include "../../mk/bsd.prefs.mk"
39 39
40.if ${OPSYS} == "DragonFly" 40.if ${OPSYS} == "DragonFly"
41.include "../../devel/libvolume_id/buildlink3.mk" 41.include "../../devel/libvolume_id/buildlink3.mk"
42CONFIGURE_ARGS+= --with-eject=/usr/sbin/cdcontrol 42CONFIGURE_ARGS+= --with-eject=/usr/sbin/cdcontrol
43CONFIGURE_ARGS+= --with-backend=freebsd 43CONFIGURE_ARGS+= --with-backend=freebsd
44PLIST_SRC= PLIST.DragonFly PLIST 44PLIST_SRC= PLIST.DragonFly PLIST
45 45
46.elif ${OPSYS} == "FreeBSD" 46.elif ${OPSYS} == "FreeBSD"
47.include "../../devel/libvolume_id/buildlink3.mk" 47.include "../../devel/libvolume_id/buildlink3.mk"
48CONFIGURE_ARGS+= --with-eject=/usr/sbin/cdcontrol 48CONFIGURE_ARGS+= --with-eject=/usr/sbin/cdcontrol
49CONFIGURE_ARGS+= --with-backend=freebsd 49CONFIGURE_ARGS+= --with-backend=freebsd
50PLIST_SRC= PLIST.FreeBSD PLIST 50PLIST_SRC= PLIST.FreeBSD PLIST
51 51
52.elif !empty(MACHINE_PLATFORM:MNetBSD-[5-9]*) 52.elif !empty(MACHINE_PLATFORM:MNetBSD-[5-9]*)
53.include "../../devel/libvolume_id/buildlink3.mk" 53.include "../../devel/libvolume_id/buildlink3.mk"
54CONFIGURE_ARGS+= --with-backend=netbsd 54CONFIGURE_ARGS+= --with-backend=netbsd
55HAL_GROUP= operator 55HAL_GROUP= operator
56 56
57.elif ${OPSYS} == "Linux" 57.elif ${OPSYS} == "Linux"
58.include "../../devel/gperf/buildlink3.mk" 58.include "../../devel/gperf/buildlink3.mk"
59.include "../../devel/libblkid/buildlink3.mk" 59.include "../../devel/libblkid/buildlink3.mk"
60.include "../../devel/libvolume_id/buildlink3.mk" 60.include "../../devel/libvolume_id/buildlink3.mk"
61.include "../../sysutils/pciutils/buildlink3.mk" 61.include "../../sysutils/pciutils/buildlink3.mk"
62CONFIGURE_ARGS+= --with-backend=linux 62CONFIGURE_ARGS+= --with-backend=linux
63MAKE_DIRS+= /etc/udev 63MAKE_DIRS+= /etc/udev
64MAKE_DIRS+= /etc/udev/rules.d 64MAKE_DIRS+= /etc/udev/rules.d
65CONF_FILES+= ${EGDIR}/90-hal.rules \ 65CONF_FILES+= ${EGDIR}/90-hal.rules \
66 /etc/udev/rules.d/90-hal.rules 66 /etc/udev/rules.d/90-hal.rules
67PLIST_VARS+= imac 67PLIST_VARS+= imac
68.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" 68.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
69PLIST.imac= yes 69PLIST.imac= yes
70CONFIGURE_ARGS+= --with-imac 70CONFIGURE_ARGS+= --with-imac
71.else 71.else
72CONFIGURE_ARGS+= --without-imac 72CONFIGURE_ARGS+= --without-imac
73.endif 73.endif
74.else # Unsupported systems 74.else # Unsupported systems
75# Pull in the dummy backend 75# Pull in the dummy backend
76.include "../../devel/libvolume_id/buildlink3.mk" 76.include "../../devel/libvolume_id/buildlink3.mk"
77CONFIGURE_ARGS+= --with-backend=dummy 77CONFIGURE_ARGS+= --with-backend=dummy
78PLIST_SRC= PLIST 78PLIST_SRC= PLIST
79.endif 79.endif
80 80
81CFLAGS.SunOS+= -Du_int32_t=uint32_t 81CFLAGS.SunOS+= -Du_int32_t=uint32_t
82 82
83BUILDLINK_TRANSFORM.SunOS+= opt:-Wl,--as-needed:-Wl,-zignore 83BUILDLINK_TRANSFORM.SunOS+= opt:-Wl,--as-needed:-Wl,-zignore
84 84
85REPLACE_INTERPRETER+= bash 85REPLACE_INTERPRETER+= bash
86REPLACE.bash.old= /bin/bash 86REPLACE.bash.old= /bin/bash
87REPLACE.bash.new= ${SH} 87REPLACE.bash.new= ${SH}
88.for halscript in luks-remove luks-setup luks-teardown system-wol-enable system-wol-enabled system-wol-supported 88.for halscript in luks-remove luks-setup luks-teardown system-wol-enable system-wol-enabled system-wol-supported
89REPLACE_FILES.bash+= tools/hal-${halscript} 89REPLACE_FILES.bash+= tools/hal-${halscript}
90.endfor 90.endfor
91 91
92HAL_USER?= haldaemon 92HAL_USER?= haldaemon
93HAL_GROUP?= haldaemon 93HAL_GROUP?= haldaemon
94CONFIGURE_ARGS+= --with-hal-user=${HAL_USER} 94CONFIGURE_ARGS+= --with-hal-user=${HAL_USER}
95CONFIGURE_ARGS+= --with-hal-group=${HAL_GROUP} 95CONFIGURE_ARGS+= --with-hal-group=${HAL_GROUP}
96CONFIGURE_ARGS+= --disable-pmu 96CONFIGURE_ARGS+= --disable-pmu
97 97
98RCD_SCRIPTS= hal 98RCD_SCRIPTS= hal
99SMF_METHODS= hal 99SMF_METHODS= hal
100 100
101.if ${HAL_GROUP} != "operator" 101.if ${HAL_GROUP} != "operator"
102PKG_GROUPS= ${HAL_GROUP} 102PKG_GROUPS= ${HAL_GROUP}
103.endif 103.endif
104PKG_USERS= ${HAL_USER}:${HAL_GROUP} 104PKG_USERS= ${HAL_USER}:${HAL_GROUP}
105PKG_HOME.haldaemon= ${VARBASE}/run/hald 105PKG_HOME.haldaemon= ${VARBASE}/run/hald
106 106
107FILES_SUBST+= HAL_USER=${HAL_USER} 107FILES_SUBST+= HAL_USER=${HAL_USER}
108FILES_SUBST+= HAL_GROUP=${HAL_GROUP} 108FILES_SUBST+= HAL_GROUP=${HAL_GROUP}
109FILES_SUBST+= PKG_HOME.haldaemon=${PKG_HOME.haldaemon} 109FILES_SUBST+= PKG_HOME.haldaemon=${PKG_HOME.haldaemon}
110 110
111PLIST_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR} 111PLIST_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR}
112 112
113TEST_TARGET= check 113TEST_TARGET= check
114 114
115post-extract: 115post-extract:
116 ${CP} -r ${FILESDIR}/hald-netbsd ${WRKSRC}/hald/netbsd 116 ${CP} -r ${FILESDIR}/hald-netbsd ${WRKSRC}/hald/netbsd
117 ${CP} -r ${FILESDIR}/tools-netbsd ${WRKSRC}/tools/netbsd 117 ${CP} -r ${FILESDIR}/tools-netbsd ${WRKSRC}/tools/netbsd
118 118
119pre-configure: 119pre-configure:
120 cd ${WRKSRC} && autoreconf -vi ${AUTORECONF_ARGS} 120 cd ${WRKSRC} && autoreconf -vi ${AUTORECONF_ARGS}
121 121
122.include "../../devel/GConf/schemas.mk" 122.include "../../devel/GConf/schemas.mk"
123.include "../../devel/glib2/buildlink3.mk" 123.include "../../devel/glib2/buildlink3.mk"
124.include "../../misc/usbids/buildlink3.mk" 124.include "../../misc/usbids/buildlink3.mk"
125.include "../../security/policykit/buildlink3.mk" 125.include "../../security/policykit/buildlink3.mk"
126.include "../../sysutils/dbus/buildlink3.mk" 126.include "../../sysutils/dbus/buildlink3.mk"
127.include "../../sysutils/dbus-glib/buildlink3.mk" 127.include "../../sysutils/dbus-glib/buildlink3.mk"
128.include "../../sysutils/hal-info/buildlink3.mk" 128.include "../../sysutils/hal-info/buildlink3.mk"
129.include "../../textproc/expat/buildlink3.mk" 129.include "../../textproc/expat/buildlink3.mk"
130.include "../../mk/bsd.pkg.mk" 130.include "../../mk/bsd.pkg.mk"

cvs diff -r1.5 -r1.6 pkgsrc/sysutils/hal/files/hald-netbsd/devinfo.c (switch to unified diff)

--- pkgsrc/sysutils/hal/files/hald-netbsd/devinfo.c 2008/12/11 15:05:01 1.5
+++ pkgsrc/sysutils/hal/files/hald-netbsd/devinfo.c 2018/05/19 13:25:36 1.6
@@ -1,418 +1,433 @@ @@ -1,418 +1,433 @@
1/*************************************************************************** 1/***************************************************************************
2 * 2 *
3 * devinfo.c : main file for drvctl-based device enumeration 3 * devinfo.c : main file for drvctl-based device enumeration
4 * 4 *
5 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 5 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
6 * Use is subject to license terms. 6 * Use is subject to license terms.
7 * 7 *
8 * Licensed under the Academic Free License version 2.1 8 * Licensed under the Academic Free License version 2.1
9 * 9 *
10 **************************************************************************/ 10 **************************************************************************/
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13# include <config.h> 13# include <config.h>
14#endif 14#endif
15 15
16#include <stdio.h> 16#include <stdio.h>
17#include <string.h> 17#include <string.h>
18 18
19#include <sys/drvctlio.h> 19#include <sys/drvctlio.h>
20 20
21#include "../osspec.h" 21#include "../osspec.h"
22#include "../logger.h" 22#include "../logger.h"
23#include "../hald.h" 23#include "../hald.h"
24#include "../hald_dbus.h" 24#include "../hald_dbus.h"
25#include "../device_info.h" 25#include "../device_info.h"
26#include "../util.h" 26#include "../util.h"
27#include "../hald_runner.h" 27#include "../hald_runner.h"
28#include "osspec_netbsd.h" 28#include "osspec_netbsd.h"
29#include "hotplug.h" 29#include "hotplug.h"
30#include "devinfo.h" 30#include "devinfo.h"
31#include "devinfo_audio.h" 31#include "devinfo_audio.h"
32#include "devinfo_video.h" 32#include "devinfo_video.h"
33#include "devinfo_pci.h" 33#include "devinfo_pci.h"
34#include "devinfo_storage.h" 34#include "devinfo_storage.h"
35#include "devinfo_mass.h" 35#include "devinfo_mass.h"
36#include "devinfo_usb.h" 36#include "devinfo_usb.h"
37#include "devinfo_misc.h" 37#include "devinfo_misc.h"
38#include "devinfo_cpu.h" 38#include "devinfo_cpu.h"
39#include "devinfo_optical.h" 39#include "devinfo_optical.h"
40/* #include "devinfo_scsipi.h" */ 40/* #include "devinfo_scsipi.h" */
41#include "drvctl.h" 41#include "drvctl.h"
42 42
43void devinfo_add_subtree(HalDevice *parent, const char *devnode, gboolean is_root); 43void devinfo_add_subtree(HalDevice *parent, const char *devnode, gboolean is_root);
44 44
45void 45void
46devinfo_add(HalDevice *parent, gchar *name) 46devinfo_add(HalDevice *parent, gchar *name)
47{ 47{
48 devinfo_add_subtree (parent, name, TRUE); 48 devinfo_add_subtree (parent, name, TRUE);
49} 49}
50 50
 51gboolean
 52devinfo_probe(HalDevice *parent, gchar *name)
 53{
 54 struct devlistargs laa;
 55
 56 if (drvctl_list (name, &laa) == -1) {
 57 HAL_INFO (("devinfo_probe: no %s device found", name));
 58 return FALSE;
 59 }
 60
 61 free (laa.l_childname);
 62
 63 return TRUE;
 64}
 65
51void 66void
52devinfo_add_subtree(HalDevice *parent, const char *devnode, gboolean is_root) 67devinfo_add_subtree(HalDevice *parent, const char *devnode, gboolean is_root)
53{ 68{
54 HalDevice *d; 69 HalDevice *d;
55 struct devlistargs laa; 70 struct devlistargs laa;
56 int i; 71 int i;
57 72
58 HAL_INFO (("add_subtree: %s", devnode)); 73 HAL_INFO (("add_subtree: %s", devnode));
59 74
60 if (parent == NULL) { 75 if (parent == NULL) {
61 parent = devinfo_add_node (NULL, devnode); 76 parent = devinfo_add_node (NULL, devnode);
62 } 77 }
63 78
64 if (drvctl_list (devnode, &laa) == -1) { 79 if (drvctl_list (devnode, &laa) == -1) {
65 HAL_INFO (("devinfo_add_subtree: drvctl_list failed")); 80 HAL_INFO (("devinfo_add_subtree: drvctl_list failed"));
66 return; 81 return;
67 } 82 }
68 83
69 for (i = 0; i < laa.l_children; i++) { 84 for (i = 0; i < laa.l_children; i++) {
70 d = devinfo_add_node (parent, laa.l_childname[i]); 85 d = devinfo_add_node (parent, laa.l_childname[i]);
71 if (d) 86 if (d)
72 devinfo_add_subtree (d, laa.l_childname[i], FALSE); 87 devinfo_add_subtree (d, laa.l_childname[i], FALSE);
73 } 88 }
74 89
75 if (laa.l_childname) 90 if (laa.l_childname)
76 free(laa.l_childname); 91 free(laa.l_childname);
77} 92}
78 93
79void 94void
80devinfo_set_default_properties (HalDevice *d, HalDevice *parent, const char *devnode, char *devfs_path) 95devinfo_set_default_properties (HalDevice *d, HalDevice *parent, const char *devnode, char *devfs_path)
81{ 96{
82 char *driver_name, *s; 97 char *driver_name, *s;
83 const char *s1; 98 const char *s1;
84 char udi[HAL_PATH_MAX]; 99 char udi[HAL_PATH_MAX];
85 100
86 if (parent != NULL) { 101 if (parent != NULL) {
87 char *pdevice = hal_device_property_get_string (parent, "netbsd.device"); 102 char *pdevice = hal_device_property_get_string (parent, "netbsd.device");
88 if (pdevice) { 103 if (pdevice) {
89 gchar *path; 104 gchar *path;
90 if (strcmp (pdevice, "mainbus0") == 0) 105 if (strcmp (pdevice, "mainbus0") == 0 || strcmp (pdevice, "armfdt0") == 0)
91 pdevice = "computer"; 106 pdevice = "computer";
92 path = g_strdup_printf ("/org/freedesktop/Hal/devices/%s", pdevice); 107 path = g_strdup_printf ("/org/freedesktop/Hal/devices/%s", pdevice);
93 hal_device_property_set_string (d, "info.parent", path); 108 hal_device_property_set_string (d, "info.parent", path);
94 g_free (path); 109 g_free (path);
95 } 110 }
96 } else { 111 } else {
97 gchar pdevnode[512]; 112 gchar pdevnode[512];
98 char *pdevice = pdevnode; 113 char *pdevice = pdevnode;
99 if (drvctl_find_parent (devnode, pdevnode) == TRUE) { 114 if (drvctl_find_parent (devnode, pdevnode) == TRUE) {
100 gchar *path; 115 gchar *path;
101 if (strcmp (pdevnode, "mainbus0") == 0) 116 if (strcmp (pdevnode, "mainbus0") == 0 || strcmp (pdevnode, "armfdt0") == 0)
102 pdevice = "computer"; 117 pdevice = "computer";
103 path = g_strdup_printf ("/org/freedesktop/Hal/devices/%s", pdevice); 118 path = g_strdup_printf ("/org/freedesktop/Hal/devices/%s", pdevice);
104 hal_device_property_set_string (d, "info.parent", path); 119 hal_device_property_set_string (d, "info.parent", path);
105 g_free (path); 120 g_free (path);
106 } else 121 } else
107 hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/local"); 122 hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/local");
108 } 123 }
109 124
110 hald_compute_udi (udi, sizeof (udi), 125 hald_compute_udi (udi, sizeof (udi),
111 "/org/freedesktop/Hal/devices/%s", devnode); 126 "/org/freedesktop/Hal/devices/%s", devnode);
112 hal_device_set_udi (d, udi); 127 hal_device_set_udi (d, udi);
113 128
114#if notyet 129#if notyet
115 if (di_prop_lookup_strings (DDI_DEV_T_ANY, node, "model", &s) > 0) { 130 if (di_prop_lookup_strings (DDI_DEV_T_ANY, node, "model", &s) > 0) {
116 hal_device_property_set_string (d, "info.product", s); 131 hal_device_property_set_string (d, "info.product", s);
117 } else { 132 } else {
118 hal_device_property_set_string (d, "info.product", di_node_name (node)); 133 hal_device_property_set_string (d, "info.product", di_node_name (node));
119 } 134 }
120#else 135#else
121 hal_device_property_set_string (d, "info.product", devnode); 136 hal_device_property_set_string (d, "info.product", devnode);
122#endif 137#endif
123 138
124 hal_device_property_set_string (d, "netbsd.device", devnode); 139 hal_device_property_set_string (d, "netbsd.device", devnode);
125 140
126#if notyet 141#if notyet
127 if ((driver_name = di_driver_name (node)) != NULL) { 142 if ((driver_name = di_driver_name (node)) != NULL) {
128 hal_device_property_set_string (d, "info.solaris.driver", 143 hal_device_property_set_string (d, "info.solaris.driver",
129 driver_name); 144 driver_name);
130 } 145 }
131 146
132 /* inherit parent's claim attributes */ 147 /* inherit parent's claim attributes */
133 if (hal_device_property_get_bool (parent, "info.claimed")) { 148 if (hal_device_property_get_bool (parent, "info.claimed")) {
134 s1 = hal_device_property_get_string (parent, "info.claimed.service"); 149 s1 = hal_device_property_get_string (parent, "info.claimed.service");
135 if (s1 != NULL) { 150 if (s1 != NULL) {
136 hal_device_property_set_bool (d, "info.claimed", TRUE); 151 hal_device_property_set_bool (d, "info.claimed", TRUE);
137 hal_device_property_set_string (d, "info.claimed.service", s1); 152 hal_device_property_set_string (d, "info.claimed.service", s1);
138 } 153 }
139 } 154 }
140#endif 155#endif
141} 156}
142 157
143/* device handlers, ordered specific to generic */ 158/* device handlers, ordered specific to generic */
144static DevinfoDevHandler *devinfo_handlers[] = { 159static DevinfoDevHandler *devinfo_handlers[] = {
145 &devinfo_computer_handler, 160 &devinfo_computer_handler,
146 &devinfo_cpu_handler, 161 &devinfo_cpu_handler,
147 &devinfo_optical_handler, 162 &devinfo_optical_handler,
148#if notyet 163#if notyet
149 &devinfo_scsipi_handler, 164 &devinfo_scsipi_handler,
150 &devinfo_ide_handler, 165 &devinfo_ide_handler,
151 &devinfo_scsi_handler, 166 &devinfo_scsi_handler,
152 &devinfo_floppy_handler, 167 &devinfo_floppy_handler,
153 &devinfo_usb_handler, 168 &devinfo_usb_handler,
154 &devinfo_pci_handler, 169 &devinfo_pci_handler,
155 &devinfo_lofi_handler, 170 &devinfo_lofi_handler,
156#endif 171#endif
157 &devinfo_audio_handler, 172 &devinfo_audio_handler,
158 &devinfo_audio_mixer_handler, 173 &devinfo_audio_mixer_handler,
159 &devinfo_audio_dsp_handler, 174 &devinfo_audio_dsp_handler,
160 &devinfo_video_handler, 175 &devinfo_video_handler,
161 &devinfo_mass_handler, 176 &devinfo_mass_handler,
162 &devinfo_default_handler, 177 &devinfo_default_handler,
163 NULL 178 NULL
164}; 179};
165 180
166HalDevice * 181HalDevice *
167devinfo_add_node(HalDevice *parent, const char *devnode) 182devinfo_add_node(HalDevice *parent, const char *devnode)
168{ 183{
169 HalDevice *d = NULL; 184 HalDevice *d = NULL;
170 char *devfs_path; 185 char *devfs_path;
171 char *device_type = NULL; 186 char *device_type = NULL;
172 DevinfoDevHandler *handler; 187 DevinfoDevHandler *handler;
173 int i; 188 int i;
174 189
175 devfs_path = g_strdup_printf ("%s", devnode); 190 devfs_path = g_strdup_printf ("%s", devnode);
176 191
177#if notyet 192#if notyet
178 (void) di_prop_lookup_strings (DDI_DEV_T_ANY, node, "device_type", 193 (void) di_prop_lookup_strings (DDI_DEV_T_ANY, node, "device_type",
179 &device_type); 194 &device_type);
180#else 195#else
181 device_type = "unknown"; 196 device_type = "unknown";
182#endif 197#endif
183 198
184 for (i = 0; (d == NULL) && (devinfo_handlers[i] != NULL); i++) { 199 for (i = 0; (d == NULL) && (devinfo_handlers[i] != NULL); i++) {
185 handler = devinfo_handlers[i]; 200 handler = devinfo_handlers[i];
186 d = handler->add (parent, devnode, devfs_path, device_type); 201 d = handler->add (parent, devnode, devfs_path, device_type);
187 } 202 }
188 203
189 g_free(devfs_path); 204 g_free(devfs_path);
190 205
191 HAL_INFO (("add_node: %s", d ? hal_device_get_udi (d) : "none")); 206 HAL_INFO (("add_node: %s", d ? hal_device_get_udi (d) : "none"));
192 return (d); 207 return (d);
193} 208}
194 209
195void 210void
196devinfo_hotplug_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler, int action, int front) 211devinfo_hotplug_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler, int action, int front)
197{ 212{
198 HotplugEvent *hotplug_event; 213 HotplugEvent *hotplug_event;
199 214
200 hotplug_event = g_new0 (HotplugEvent, 1); 215 hotplug_event = g_new0 (HotplugEvent, 1);
201 hotplug_event->action = action; 216 hotplug_event->action = action;
202 hotplug_event->type = HOTPLUG_EVENT_DEVFS; 217 hotplug_event->type = HOTPLUG_EVENT_DEVFS;
203 hotplug_event->d = d; 218 hotplug_event->d = d;
204 strlcpy (hotplug_event->un.devfs.devfs_path, devfs_path, 219 strlcpy (hotplug_event->un.devfs.devfs_path, devfs_path,
205 sizeof (hotplug_event->un.devfs.devfs_path)); 220 sizeof (hotplug_event->un.devfs.devfs_path));
206 hotplug_event->un.devfs.handler = handler; 221 hotplug_event->un.devfs.handler = handler;
207 222
208 hotplug_event_enqueue (hotplug_event, front); 223 hotplug_event_enqueue (hotplug_event, front);
209} 224}
210 225
211void 226void
212devinfo_add_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler) 227devinfo_add_enqueue(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler)
213{ 228{
214 devinfo_hotplug_enqueue (d, devfs_path, handler, HOTPLUG_ACTION_ADD, 0); 229 devinfo_hotplug_enqueue (d, devfs_path, handler, HOTPLUG_ACTION_ADD, 0);
215} 230}
216 231
217void 232void
218devinfo_add_enqueue_at_front(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler) 233devinfo_add_enqueue_at_front(HalDevice *d, gchar *devfs_path, DevinfoDevHandler *handler)
219{ 234{
220 devinfo_hotplug_enqueue (d, devfs_path, handler, HOTPLUG_ACTION_ADD, 1); 235 devinfo_hotplug_enqueue (d, devfs_path, handler, HOTPLUG_ACTION_ADD, 1);
221} 236}
222 237
223void 238void
224devinfo_remove_enqueue(gchar *devfs_path, DevinfoDevHandler *handler) 239devinfo_remove_enqueue(gchar *devfs_path, DevinfoDevHandler *handler)
225{ 240{
226 devinfo_hotplug_enqueue (NULL, devfs_path, handler, HOTPLUG_ACTION_REMOVE, 0); 241 devinfo_hotplug_enqueue (NULL, devfs_path, handler, HOTPLUG_ACTION_REMOVE, 0);
227} 242}
228 243
229void 244void
230devinfo_callouts_add_done (HalDevice *d, gpointer userdata1, gpointer userdata2) 245devinfo_callouts_add_done (HalDevice *d, gpointer userdata1, gpointer userdata2)
231{ 246{
232 void *end_token = (void *) userdata1; 247 void *end_token = (void *) userdata1;
233 248
234 /* Move from temporary to global device store */ 249 /* Move from temporary to global device store */
235 hal_device_store_remove (hald_get_tdl (), d); 250 hal_device_store_remove (hald_get_tdl (), d);
236 hal_device_store_add (hald_get_gdl (), d); 251 hal_device_store_add (hald_get_gdl (), d);
237 252
238 hotplug_event_end (end_token); 253 hotplug_event_end (end_token);
239} 254}
240 255
241void 256void
242devinfo_callouts_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2) 257devinfo_callouts_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2)
243{ 258{
244 void *end_token = (void *) userdata1; 259 void *end_token = (void *) userdata1;
245 260
246 /* Discard device if probing reports failure */ 261 /* Discard device if probing reports failure */
247 if (exit_type != HALD_RUN_SUCCESS || (return_code != 0)) { 262 if (exit_type != HALD_RUN_SUCCESS || (return_code != 0)) {
248 HAL_INFO (("Probing for %s failed %d", hal_device_get_udi (d), return_code)); 263 HAL_INFO (("Probing for %s failed %d", hal_device_get_udi (d), return_code));
249 hal_device_store_remove (hald_get_tdl (), d); 264 hal_device_store_remove (hald_get_tdl (), d);
250 g_object_unref (d); 265 g_object_unref (d);
251 hotplug_event_end (end_token); 266 hotplug_event_end (end_token);
252 return; 267 return;
253 } 268 }
254 269
255 /* Merge properties from .fdi files */ 270 /* Merge properties from .fdi files */
256 di_search_and_merge (d, DEVICE_INFO_TYPE_INFORMATION); 271 di_search_and_merge (d, DEVICE_INFO_TYPE_INFORMATION);
257 di_search_and_merge (d, DEVICE_INFO_TYPE_POLICY); 272 di_search_and_merge (d, DEVICE_INFO_TYPE_POLICY);
258 273
259 hal_util_callout_device_add (d, devinfo_callouts_add_done, end_token, NULL); 274 hal_util_callout_device_add (d, devinfo_callouts_add_done, end_token, NULL);
260} 275}
261 276
262void 277void
263devinfo_callouts_preprobing_done (HalDevice *d, gpointer userdata1, gpointer userdata2) 278devinfo_callouts_preprobing_done (HalDevice *d, gpointer userdata1, gpointer userdata2)
264{ 279{
265 void *end_token = (void *) userdata1; 280 void *end_token = (void *) userdata1;
266 DevinfoDevHandler *handler = (DevinfoDevHandler *) userdata2; 281 DevinfoDevHandler *handler = (DevinfoDevHandler *) userdata2;
267 void (*probing_done) (HalDevice *, guint32, gint, char **, gpointer, gpointer); 282 void (*probing_done) (HalDevice *, guint32, gint, char **, gpointer, gpointer);
268 const gchar *prober; 283 const gchar *prober;
269 int prober_timeout; 284 int prober_timeout;
270 285
271 if (hal_device_property_get_bool (d, "info.ignore")) { 286 if (hal_device_property_get_bool (d, "info.ignore")) {
272 HAL_INFO (("Preprobing merged info.ignore==TRUE")); 287 HAL_INFO (("Preprobing merged info.ignore==TRUE"));
273 288
274 /* Leave device with info.ignore==TRUE so we won't pick up children */ 289 /* Leave device with info.ignore==TRUE so we won't pick up children */
275 hal_device_property_remove (d, "info.category"); 290 hal_device_property_remove (d, "info.category");
276 hal_device_property_remove (d, "info.capabilities"); 291 hal_device_property_remove (d, "info.capabilities");
277 292
278 hal_device_store_remove (hald_get_tdl (), d); 293 hal_device_store_remove (hald_get_tdl (), d);
279 hal_device_store_add (hald_get_gdl (), d); 294 hal_device_store_add (hald_get_gdl (), d);
280 295
281 hotplug_event_end (end_token); 296 hotplug_event_end (end_token);
282 return; 297 return;
283 } 298 }
284 299
285 if (handler != NULL && handler->get_prober != NULL) { 300 if (handler != NULL && handler->get_prober != NULL) {
286 prober = handler->get_prober (d, &prober_timeout); 301 prober = handler->get_prober (d, &prober_timeout);
287 } else { 302 } else {
288 prober = NULL; 303 prober = NULL;
289 } 304 }
290 305
291 if (handler->probing_done != NULL) { 306 if (handler->probing_done != NULL) {
292 probing_done = handler->probing_done; 307 probing_done = handler->probing_done;
293 } else { 308 } else {
294 probing_done = devinfo_callouts_probing_done; 309 probing_done = devinfo_callouts_probing_done;
295 } 310 }
296 311
297 if (prober != NULL) { 312 if (prober != NULL) {
298 /* probe the device */ 313 /* probe the device */
299 HAL_INFO(("Probing udi=%s", hal_device_get_udi (d))); 314 HAL_INFO(("Probing udi=%s", hal_device_get_udi (d)));
300 hald_runner_run (d, 315 hald_runner_run (d,
301 prober, NULL, 316 prober, NULL,
302 prober_timeout, 317 prober_timeout,
303 probing_done, 318 probing_done,
304 (gpointer) end_token, (gpointer) handler); 319 (gpointer) end_token, (gpointer) handler);
305 } else { 320 } else {
306 probing_done (d, 0, 0, NULL, userdata1, userdata2); 321 probing_done (d, 0, 0, NULL, userdata1, userdata2);
307 } 322 }
308} 323}
309 324
310/* This is the beginning of hotplug even handling */ 325/* This is the beginning of hotplug even handling */
311void 326void
312hotplug_event_begin_add_devinfo (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token) 327hotplug_event_begin_add_devinfo (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token)
313{ 328{
314 HAL_INFO(("Preprobing udi=%s", hal_device_get_udi (d))); 329 HAL_INFO(("Preprobing udi=%s", hal_device_get_udi (d)));
315 330
316 if (parent != NULL && hal_device_property_get_bool (parent, "info.ignore")) { 331 if (parent != NULL && hal_device_property_get_bool (parent, "info.ignore")) {
317 HAL_INFO (("Ignoring device since parent has info.ignore==TRUE")); 332 HAL_INFO (("Ignoring device since parent has info.ignore==TRUE"));
318 333
319 hotplug_event_end (end_token); 334 hotplug_event_end (end_token);
320 return; 335 return;
321 } 336 }
322 337
323 /* add to TDL so preprobing callouts and prober can access it */ 338 /* add to TDL so preprobing callouts and prober can access it */
324 hal_device_store_add (hald_get_tdl (), d); 339 hal_device_store_add (hald_get_tdl (), d);
325 340
326#if 0 341#if 0
327 /* Process preprobe fdi files */ 342 /* Process preprobe fdi files */
328 di_search_and_merge (d, DEVICE_INFO_TYPE_PREPROBE); 343 di_search_and_merge (d, DEVICE_INFO_TYPE_PREPROBE);
329#endif 344#endif
330 345
331 /* Run preprobe callouts */ 346 /* Run preprobe callouts */
332 hal_util_callout_device_preprobe (d, devinfo_callouts_preprobing_done, end_token, handler); 347 hal_util_callout_device_preprobe (d, devinfo_callouts_preprobing_done, end_token, handler);
333} 348}
334 349
335void 350void
336devinfo_remove (gchar *devfs_path) 351devinfo_remove (gchar *devfs_path)
337{ 352{
338 devinfo_remove_enqueue ((gchar *)devfs_path, NULL); 353 devinfo_remove_enqueue ((gchar *)devfs_path, NULL);
339} 354}
340 355
341/* generate hotplug event for each device in this branch */ 356/* generate hotplug event for each device in this branch */
342void 357void
343devinfo_remove_branch (gchar *devnode, HalDevice *d) 358devinfo_remove_branch (gchar *devnode, HalDevice *d)
344{ 359{
345 GSList *i; 360 GSList *i;
346 GSList *children; 361 GSList *children;
347 HalDevice *child; 362 HalDevice *child;
348 char *child_devfs_path; 363 char *child_devfs_path;
349 364
350 if (d == NULL) { 365 if (d == NULL) {
351 d = hal_device_store_match_key_value_string (hald_get_gdl (), 366 d = hal_device_store_match_key_value_string (hald_get_gdl (),
352 "netbsd.device", devnode); 367 "netbsd.device", devnode);
353 if (d == NULL) 368 if (d == NULL)
354 return; 369 return;
355 } 370 }
356 371
357 HAL_INFO (("remove_branch: %s %s\n", devnode, hal_device_get_udi (d))); 372 HAL_INFO (("remove_branch: %s %s\n", devnode, hal_device_get_udi (d)));
358 373
359 /* first remove children */ 374 /* first remove children */
360 children = hal_device_store_match_multiple_key_value_string (hald_get_gdl(), 375 children = hal_device_store_match_multiple_key_value_string (hald_get_gdl(),
361 "info.parent", hal_device_get_udi (d)); 376 "info.parent", hal_device_get_udi (d));
362 for (i = children; i != NULL; i = g_slist_next (i)) { 377 for (i = children; i != NULL; i = g_slist_next (i)) {
363 child = HAL_DEVICE (i->data); 378 child = HAL_DEVICE (i->data);
364 HAL_INFO (("remove_branch: child %s\n", hal_device_get_udi (child))); 379 HAL_INFO (("remove_branch: child %s\n", hal_device_get_udi (child)));
365 devinfo_remove_branch ((gchar *)hal_device_property_get_string (child, "netbsd.device"), child); 380 devinfo_remove_branch ((gchar *)hal_device_property_get_string (child, "netbsd.device"), child);
366 } 381 }
367 g_slist_free (children); 382 g_slist_free (children);
368 HAL_INFO (("remove_branch: done with children")); 383 HAL_INFO (("remove_branch: done with children"));
369 384
370 /* then remove self */ 385 /* then remove self */
371 HAL_INFO (("remove_branch: queueing %s", devnode)); 386 HAL_INFO (("remove_branch: queueing %s", devnode));
372 devinfo_remove_enqueue (devnode, NULL); 387 devinfo_remove_enqueue (devnode, NULL);
373} 388}
374 389
375void 390void
376devinfo_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2) 391devinfo_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2)
377{ 392{
378 void *end_token = (void *) userdata1; 393 void *end_token = (void *) userdata1;
379 394
380 HAL_INFO (("Remove callouts completed udi=%s", hal_device_get_udi (d))); 395 HAL_INFO (("Remove callouts completed udi=%s", hal_device_get_udi (d)));
381 396
382 if (!hal_device_store_remove (hald_get_gdl (), d)) { 397 if (!hal_device_store_remove (hald_get_gdl (), d)) {
383 HAL_WARNING (("Error removing device")); 398 HAL_WARNING (("Error removing device"));
384 } 399 }
385 g_object_unref (d); 400 g_object_unref (d);
386 401
387 hotplug_event_end (end_token); 402 hotplug_event_end (end_token);
388} 403}
389 404
390void 405void
391hotplug_event_begin_remove_devinfo (HalDevice *d, gchar *devfs_path, void *end_token) 406hotplug_event_begin_remove_devinfo (HalDevice *d, gchar *devfs_path, void *end_token)
392{ 407{
393#if notyet 408#if notyet
394 if (hal_device_has_capability (d, "volume")) { 409 if (hal_device_has_capability (d, "volume")) {
395 devinfo_volume_hotplug_begin_remove (d, devfs_path, end_token); 410 devinfo_volume_hotplug_begin_remove (d, devfs_path, end_token);
396 } else { 411 } else {
397 hal_util_callout_device_remove (d, devinfo_callouts_remove_done, end_token, NULL); 412 hal_util_callout_device_remove (d, devinfo_callouts_remove_done, end_token, NULL);
398 } 413 }
399#else 414#else
400#warning hotplug_event_begin_remove_devinfo TODO 415#warning hotplug_event_begin_remove_devinfo TODO
401 hal_util_callout_device_remove (d, devinfo_callouts_remove_done, end_token, NULL); 416 hal_util_callout_device_remove (d, devinfo_callouts_remove_done, end_token, NULL);
402#endif 417#endif
403} 418}
404 419
405gboolean 420gboolean
406devinfo_device_rescan (HalDevice *d) 421devinfo_device_rescan (HalDevice *d)
407{ 422{
408#if notyet 423#if notyet
409 if (hal_device_has_capability (d, "block")) { 424 if (hal_device_has_capability (d, "block")) {
410 return (devinfo_storage_device_rescan (d)); 425 return (devinfo_storage_device_rescan (d));
411 } else { 426 } else {
412 return (FALSE); 427 return (FALSE);
413 } 428 }
414#else 429#else
415#warning devinfo_device_rescan TODO 430#warning devinfo_device_rescan TODO
416 return FALSE; 431 return FALSE;
417#endif 432#endif
418} 433}

cvs diff -r1.1 -r1.2 pkgsrc/sysutils/hal/files/hald-netbsd/devinfo.h (switch to unified diff)

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

cvs diff -r1.1 -r1.2 pkgsrc/sysutils/hal/files/hald-netbsd/hotplug.c (switch to unified diff)

--- pkgsrc/sysutils/hal/files/hald-netbsd/hotplug.c 2008/11/25 23:10:23 1.1
+++ pkgsrc/sysutils/hal/files/hald-netbsd/hotplug.c 2018/05/19 13:25:36 1.2
@@ -1,204 +1,204 @@ @@ -1,204 +1,204 @@
1/*************************************************************************** 1/***************************************************************************
2 * 2 *
3 * hotplug.c : HAL-internal hotplug events 3 * hotplug.c : HAL-internal hotplug events
4 * 4 *
5 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 5 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
6 * Use is subject to license terms. 6 * Use is subject to license terms.
7 * 7 *
8 * Licensed under the Academic Free License version 2.1 8 * Licensed under the Academic Free License version 2.1
9 * 9 *
10 **************************************************************************/ 10 **************************************************************************/
11 11
12#pragma ident "@(#)hotplug.c 1.2 06/10/13 SMI" 12#pragma ident "@(#)hotplug.c 1.2 06/10/13 SMI"
13 13
14#ifdef HAVE_CONFIG_H 14#ifdef HAVE_CONFIG_H
15# include <config.h> 15# include <config.h>
16#endif 16#endif
17 17
18#include <stdio.h> 18#include <stdio.h>
19#include <string.h> 19#include <string.h>
20#include <errno.h> 20#include <errno.h>
21#include <sys/types.h> 21#include <sys/types.h>
22#include <sys/stat.h> 22#include <sys/stat.h>
23#include <sys/un.h> 23#include <sys/un.h>
24#include <sys/utsname.h> 24#include <sys/utsname.h>
25#include <unistd.h> 25#include <unistd.h>
26 26
27#include <glib.h> 27#include <glib.h>
28#include <dbus/dbus.h> 28#include <dbus/dbus.h>
29#include <dbus/dbus-glib.h> 29#include <dbus/dbus-glib.h>
30 30
31#include "../osspec.h" 31#include "../osspec.h"
32#include "../logger.h" 32#include "../logger.h"
33#include "../hald.h" 33#include "../hald.h"
34#include "../device_info.h" 34#include "../device_info.h"
35 35
36#include "osspec_netbsd.h" 36#include "osspec_netbsd.h"
37#include "hotplug.h" 37#include "hotplug.h"
38#include "devinfo.h" 38#include "devinfo.h"
39 39
40/** Queue of ordered hotplug events */ 40/** Queue of ordered hotplug events */
41GQueue *hotplug_event_queue; 41GQueue *hotplug_event_queue;
42 42
43/** List of HotplugEvent objects we are currently processing */ 43/** List of HotplugEvent objects we are currently processing */
44GSList *hotplug_events_in_progress = NULL; 44GSList *hotplug_events_in_progress = NULL;
45 45
46static void hotplug_event_begin (HotplugEvent *hotplug_event); 46static void hotplug_event_begin (HotplugEvent *hotplug_event);
47 47
48void  48void
49hotplug_event_end (void *end_token) 49hotplug_event_end (void *end_token)
50{ 50{
51 HotplugEvent *hotplug_event = (HotplugEvent *) end_token; 51 HotplugEvent *hotplug_event = (HotplugEvent *) end_token;
52 52
53 hotplug_events_in_progress = g_slist_remove (hotplug_events_in_progress, hotplug_event); 53 hotplug_events_in_progress = g_slist_remove (hotplug_events_in_progress, hotplug_event);
54 g_free (hotplug_event); 54 g_free (hotplug_event);
55 hotplug_event_process_queue (); 55 hotplug_event_process_queue ();
56} 56}
57 57
58static void 58static void
59hotplug_event_begin_devfs_add (HotplugEvent *hotplug_event, HalDevice *d) 59hotplug_event_begin_devfs_add (HotplugEvent *hotplug_event, HalDevice *d)
60{ 60{
61 HalDevice *parent; 61 HalDevice *parent;
62 const gchar *parent_udi; 62 const gchar *parent_udi;
63 void (*begin_add_func) (HalDevice *, HalDevice *, DevinfoDevHandler *, void *); 63 void (*begin_add_func) (HalDevice *, HalDevice *, DevinfoDevHandler *, void *);
64 64
65 if (d != NULL) { 65 if (d != NULL) {
66 /* XXX */ 66 /* XXX */
67 HAL_ERROR (("devpath %s already present in store, ignore event", hotplug_event->un.devfs.devfs_path)); 67 HAL_ERROR (("devpath %s already present in store, ignore event", hotplug_event->un.devfs.devfs_path));
68 hotplug_event_end ((void *) hotplug_event); 68 hotplug_event_end ((void *) hotplug_event);
69 return; 69 return;
70 } 70 }
71 71
72 /* find parent */ 72 /* find parent */
73 parent_udi = hal_device_property_get_string (hotplug_event->d, "info.parent"); 73 parent_udi = hal_device_property_get_string (hotplug_event->d, "info.parent");
74 if (parent_udi == NULL || strlen(parent_udi) == 0) { 74 if (parent_udi == NULL || strlen(parent_udi) == 0) {
75 parent = NULL; 75 parent = NULL;
76 HAL_INFO (("no info.parent parameter found")); 76 HAL_INFO (("no info.parent parameter found"));
77 } else { 77 } else {
78 parent = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", parent_udi); 78 parent = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", parent_udi);
79 if (parent == NULL) 79 if (parent == NULL)
80 HAL_INFO (("no info.udi=%s parameter found", parent_udi)); 80 HAL_INFO (("no info.udi=%s parameter found", parent_udi));
81 } 81 }
82 82
83 if (parent == NULL) { 83 if (parent == NULL) {
84 gchar pdevnode[512]; 84 gchar pdevnode[512];
85 HAL_INFO (("couldn't look up %s parent by udi, trying netbsd.device", hotplug_event->un.devfs.devfs_path)); 85 HAL_INFO (("couldn't look up %s parent by udi, trying netbsd.device", hotplug_event->un.devfs.devfs_path));
86 if (drvctl_find_parent (hotplug_event->un.devfs.devfs_path, pdevnode) == TRUE) 86 if (drvctl_find_parent (hotplug_event->un.devfs.devfs_path, pdevnode) == TRUE)
87 parent = hal_device_store_match_key_value_string (hald_get_gdl (), "netbsd.device", pdevnode); 87 parent = hal_device_store_match_key_value_string (hald_get_gdl (), "netbsd.device", pdevnode);
88 } 88 }
89 89
90 /* only root node is allowed to be orphan */ 90 /* only root node is allowed to be orphan */
91 if (parent == NULL) { 91 if (parent == NULL) {
92 if (strcmp(hotplug_event->un.devfs.devfs_path, "mainbus0") != 0) { 92 if (strcmp(hotplug_event->un.devfs.devfs_path, "mainbus0") != 0 && strcmp(hotplug_event->un.devfs.devfs_path, "armfdt0") != 0) {
93 HAL_ERROR (("Parent is NULL devfs_path=%s parent_udi=%s", hotplug_event->un.devfs.devfs_path, parent_udi ? parent_udi : "<null>")); 93 HAL_ERROR (("Parent is NULL devfs_path=%s parent_udi=%s", hotplug_event->un.devfs.devfs_path, parent_udi ? parent_udi : "<null>"));
94 hotplug_event_end ((void *) hotplug_event); 94 hotplug_event_end ((void *) hotplug_event);
95 return; 95 return;
96 } 96 }
97 } 97 }
98 98
99 /* children of ignored parent should be ignored */ 99 /* children of ignored parent should be ignored */
100 if (hal_device_property_get_bool (parent, "info.ignore")) { 100 if (hal_device_property_get_bool (parent, "info.ignore")) {
101 HAL_INFO (("parent ignored %s", parent_udi)); 101 HAL_INFO (("parent ignored %s", parent_udi));
102 hotplug_event_end ((void *) hotplug_event); 102 hotplug_event_end ((void *) hotplug_event);
103 return; 103 return;
104 } 104 }
105 105
106 /* custom or generic add function */ 106 /* custom or generic add function */
107 begin_add_func = hotplug_event->un.devfs.handler->hotplug_begin_add; 107 begin_add_func = hotplug_event->un.devfs.handler->hotplug_begin_add;
108 if (begin_add_func == NULL) { 108 if (begin_add_func == NULL) {
109 begin_add_func = hotplug_event_begin_add_devinfo; 109 begin_add_func = hotplug_event_begin_add_devinfo;
110 } 110 }
111 begin_add_func (hotplug_event->d,  111 begin_add_func (hotplug_event->d,
112 parent, 112 parent,
113 hotplug_event->un.devfs.handler,  113 hotplug_event->un.devfs.handler,
114 (void *) hotplug_event); 114 (void *) hotplug_event);
115} 115}
116 116
117static void 117static void
118hotplug_event_begin_devfs_remove (HotplugEvent *hotplug_event, HalDevice *d) 118hotplug_event_begin_devfs_remove (HotplugEvent *hotplug_event, HalDevice *d)
119{ 119{
120 if (d == NULL) { 120 if (d == NULL) {
121 HAL_ERROR (("devpath %s not present in store, ignore event", hotplug_event->un.devfs.devfs_path)); 121 HAL_ERROR (("devpath %s not present in store, ignore event", hotplug_event->un.devfs.devfs_path));
122 hotplug_event_end ((void *) hotplug_event); 122 hotplug_event_end ((void *) hotplug_event);
123 return; 123 return;
124 } 124 }
125 HAL_INFO (("hotplug_event_begin_devfs_remove %s", hal_device_get_udi (d))); 125 HAL_INFO (("hotplug_event_begin_devfs_remove %s", hal_device_get_udi (d)));
126 126
127 hotplug_event_begin_remove_devinfo(d,  127 hotplug_event_begin_remove_devinfo(d,
128 hotplug_event->un.devfs.devfs_path,  128 hotplug_event->un.devfs.devfs_path,
129 (void *) hotplug_event); 129 (void *) hotplug_event);
130} 130}
131 131
132static void 132static void
133hotplug_event_begin_devfs (HotplugEvent *hotplug_event) 133hotplug_event_begin_devfs (HotplugEvent *hotplug_event)
134{ 134{
135 HalDevice *d; 135 HalDevice *d;
136 136
137 HAL_INFO (("hotplug_event_begin_devfs: %s", hotplug_event->un.devfs.devfs_path)); 137 HAL_INFO (("hotplug_event_begin_devfs: %s", hotplug_event->un.devfs.devfs_path));
138 d = hal_device_store_match_key_value_string (hald_get_gdl (), 138 d = hal_device_store_match_key_value_string (hald_get_gdl (),
139 "netbsd.device", 139 "netbsd.device",
140 hotplug_event->un.devfs.devfs_path); 140 hotplug_event->un.devfs.devfs_path);
141 141
142 if (hotplug_event->action == HOTPLUG_ACTION_ADD) { 142 if (hotplug_event->action == HOTPLUG_ACTION_ADD) {
143 hotplug_event_begin_devfs_add (hotplug_event, d); 143 hotplug_event_begin_devfs_add (hotplug_event, d);
144 } else if (hotplug_event->action == HOTPLUG_ACTION_REMOVE) { 144 } else if (hotplug_event->action == HOTPLUG_ACTION_REMOVE) {
145 hotplug_event_begin_devfs_remove (hotplug_event, d); 145 hotplug_event_begin_devfs_remove (hotplug_event, d);
146 } else { 146 } else {
147 hotplug_event_end ((void *) hotplug_event); 147 hotplug_event_end ((void *) hotplug_event);
148 } 148 }
149} 149}
150 150
151static void 151static void
152hotplug_event_begin (HotplugEvent *hotplug_event) 152hotplug_event_begin (HotplugEvent *hotplug_event)
153{ 153{
154 switch (hotplug_event->type) { 154 switch (hotplug_event->type) {
155 155
156 case HOTPLUG_EVENT_DEVFS: 156 case HOTPLUG_EVENT_DEVFS:
157 hotplug_event_begin_devfs (hotplug_event); 157 hotplug_event_begin_devfs (hotplug_event);
158 break; 158 break;
159 159
160 default: 160 default:
161 HAL_ERROR (("Unknown hotplug event type %d", hotplug_event->type)); 161 HAL_ERROR (("Unknown hotplug event type %d", hotplug_event->type));
162 hotplug_event_end ((void *) hotplug_event); 162 hotplug_event_end ((void *) hotplug_event);
163 break; 163 break;
164 } 164 }
165} 165}
166 166
167void  167void
168hotplug_event_enqueue (HotplugEvent *hotplug_event, int front) 168hotplug_event_enqueue (HotplugEvent *hotplug_event, int front)
169{ 169{
170 if (hotplug_event_queue == NULL) 170 if (hotplug_event_queue == NULL)
171 hotplug_event_queue = g_queue_new (); 171 hotplug_event_queue = g_queue_new ();
172 172
173 if (front) { 173 if (front) {
174 g_queue_push_head (hotplug_event_queue, hotplug_event); 174 g_queue_push_head (hotplug_event_queue, hotplug_event);
175 } else { 175 } else {
176 g_queue_push_tail (hotplug_event_queue, hotplug_event); 176 g_queue_push_tail (hotplug_event_queue, hotplug_event);
177 } 177 }
178} 178}
179 179
180void  180void
181hotplug_event_process_queue (void) 181hotplug_event_process_queue (void)
182{ 182{
183 HotplugEvent *hotplug_event; 183 HotplugEvent *hotplug_event;
184 184
185 if (hotplug_events_in_progress == NULL &&  185 if (hotplug_events_in_progress == NULL &&
186 (hotplug_event_queue == NULL || g_queue_is_empty (hotplug_event_queue))) { 186 (hotplug_event_queue == NULL || g_queue_is_empty (hotplug_event_queue))) {
187 hotplug_queue_now_empty (); 187 hotplug_queue_now_empty ();
188 goto out; 188 goto out;
189 } 189 }
190 190
191 /* do not process events if some other event is in progress */ 191 /* do not process events if some other event is in progress */
192 if (hotplug_events_in_progress != NULL && g_slist_length (hotplug_events_in_progress) > 0) 192 if (hotplug_events_in_progress != NULL && g_slist_length (hotplug_events_in_progress) > 0)
193 goto out; 193 goto out;
194 194
195 hotplug_event = g_queue_pop_head (hotplug_event_queue); 195 hotplug_event = g_queue_pop_head (hotplug_event_queue);
196 if (hotplug_event == NULL) 196 if (hotplug_event == NULL)
197 goto out; 197 goto out;
198 198
199 hotplug_events_in_progress = g_slist_append (hotplug_events_in_progress, hotplug_event); 199 hotplug_events_in_progress = g_slist_append (hotplug_events_in_progress, hotplug_event);
200 hotplug_event_begin (hotplug_event); 200 hotplug_event_begin (hotplug_event);
201 201
202out: 202out:
203 ;  203 ;
204} 204}

cvs diff -r1.6 -r1.7 pkgsrc/sysutils/hal/files/hald-netbsd/devinfo_misc.c (switch to unified diff)

--- pkgsrc/sysutils/hal/files/hald-netbsd/devinfo_misc.c 2015/01/25 18:46:09 1.6
+++ pkgsrc/sysutils/hal/files/hald-netbsd/devinfo_misc.c 2018/05/19 13:25:36 1.7
@@ -1,168 +1,168 @@ @@ -1,168 +1,168 @@
1/*************************************************************************** 1/***************************************************************************
2 * 2 *
3 * devinfo_misc : misc devices 3 * devinfo_misc : misc devices
4 * 4 *
5 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 5 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
6 * Use is subject to license terms. 6 * Use is subject to license terms.
7 * 7 *
8 * Licensed under the Academic Free License version 2.1 8 * Licensed under the Academic Free License version 2.1
9 * 9 *
10 **************************************************************************/ 10 **************************************************************************/
11 11
12#include <sys/types.h> 12#include <sys/types.h>
13#include <sys/sysctl.h> 13#include <sys/sysctl.h>
14 14
15#ifdef HAVE_CONFIG_H 15#ifdef HAVE_CONFIG_H
16# include <config.h> 16# include <config.h>
17#endif 17#endif
18 18
19#include <sys/utsname.h> 19#include <sys/utsname.h>
20#include <stdio.h> 20#include <stdio.h>
21#include <string.h> 21#include <string.h>
22 22
23#include "../osspec.h" 23#include "../osspec.h"
24#include "../logger.h" 24#include "../logger.h"
25#include "../hald.h" 25#include "../hald.h"
26#include "../hald_dbus.h" 26#include "../hald_dbus.h"
27#include "../device_info.h" 27#include "../device_info.h"
28#include "../util.h" 28#include "../util.h"
29#include "devinfo_misc.h" 29#include "devinfo_misc.h"
30#include "drvctl.h" 30#include "drvctl.h"
31 31
32static HalDevice *devinfo_computer_add(HalDevice *, const char *, char *, char *); 32static HalDevice *devinfo_computer_add(HalDevice *, const char *, char *, char *);
33static HalDevice *devinfo_cpu_add(HalDevice *, const char *, char *,char *); 33static HalDevice *devinfo_cpu_add(HalDevice *, const char *, char *,char *);
34static HalDevice *devinfo_default_add(HalDevice *, const char *, char *, char *); 34static HalDevice *devinfo_default_add(HalDevice *, const char *, char *, char *);
35 35
36DevinfoDevHandler devinfo_computer_handler = { 36DevinfoDevHandler devinfo_computer_handler = {
37 devinfo_computer_add, 37 devinfo_computer_add,
38 NULL, 38 NULL,
39 NULL, 39 NULL,
40 NULL, 40 NULL,
41 NULL, 41 NULL,
42 NULL 42 NULL
43}; 43};
44DevinfoDevHandler devinfo_cpu_handler = { 44DevinfoDevHandler devinfo_cpu_handler = {
45 devinfo_cpu_add, 45 devinfo_cpu_add,
46 NULL, 46 NULL,
47 NULL, 47 NULL,
48 NULL, 48 NULL,
49 NULL, 49 NULL,
50 NULL 50 NULL
51}; 51};
52DevinfoDevHandler devinfo_default_handler = { 52DevinfoDevHandler devinfo_default_handler = {
53 devinfo_default_add, 53 devinfo_default_add,
54 NULL, 54 NULL,
55 NULL, 55 NULL,
56 NULL, 56 NULL,
57 NULL, 57 NULL,
58 NULL 58 NULL
59}; 59};
60 60
61static HalDevice * 61static HalDevice *
62devinfo_computer_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) 62devinfo_computer_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type)
63{ 63{
64 HalDevice *d; 64 HalDevice *d;
65 struct utsname un; 65 struct utsname un;
66 char acpi_supported_states[20]; 66 char acpi_supported_states[20];
67 size_t len = sizeof(acpi_supported_states); 67 size_t len = sizeof(acpi_supported_states);
68 68
69 if (strcmp (devnode, "mainbus0") != 0) { 69 if (strcmp (devnode, "mainbus0") != 0 && strcmp (devnode, "armfdt0") != 0) {
70 return (NULL); 70 return (NULL);
71 } 71 }
72 72
73 HAL_INFO (("devinfo_computer_add parent=%p devnode=%s devfs_path=%s device_type=%s", 73 HAL_INFO (("devinfo_computer_add parent=%p devnode=%s devfs_path=%s device_type=%s",
74 parent, devnode, devfs_path, device_type)); 74 parent, devnode, devfs_path, device_type));
75 75
76 d = hal_device_new (); 76 d = hal_device_new ();
77 77
78 hal_device_property_set_string (d, "info.subsystem", "unknown"); 78 hal_device_property_set_string (d, "info.subsystem", "unknown");
79 hal_device_property_set_string (d, "info.product", "Computer"); 79 hal_device_property_set_string (d, "info.product", "Computer");
80 hal_device_set_udi (d, "/org/freedesktop/Hal/devices/computer"); 80 hal_device_set_udi (d, "/org/freedesktop/Hal/devices/computer");
81 hal_device_property_set_string (d, "netbsd.device", devnode); 81 hal_device_property_set_string (d, "netbsd.device", devnode);
82 82
83 if (uname (&un) >= 0) { 83 if (uname (&un) >= 0) {
84 hal_device_property_set_string (d, "system.kernel.name", un.sysname); 84 hal_device_property_set_string (d, "system.kernel.name", un.sysname);
85 hal_device_property_set_string (d, "system.kernel.version", un.release); 85 hal_device_property_set_string (d, "system.kernel.version", un.release);
86 hal_device_property_set_string (d, "system.kernel.machine", un.machine); 86 hal_device_property_set_string (d, "system.kernel.machine", un.machine);
87 } 87 }
88 88
89 devinfo_add_enqueue (d, devfs_path, &devinfo_computer_handler); 89 devinfo_add_enqueue (d, devfs_path, &devinfo_computer_handler);
90 90
91 if (sysctlbyname ("hw.acpi.supported_states", acpi_supported_states, &len, NULL, 0) == 0 || 91 if (sysctlbyname ("hw.acpi.supported_states", acpi_supported_states, &len, NULL, 0) == 0 ||
92 sysctlbyname ("hw.acpi.sleep.states", acpi_supported_states, &len, NULL, 0) == 0) { 92 sysctlbyname ("hw.acpi.sleep.states", acpi_supported_states, &len, NULL, 0) == 0) {
93 hal_device_property_set_string (d, "power_management.type", "acpi"); 93 hal_device_property_set_string (d, "power_management.type", "acpi");
94 if (strstr (acpi_supported_states, "S3") != NULL) 94 if (strstr (acpi_supported_states, "S3") != NULL)
95 hal_device_property_set_bool (d, "power_management.can_suspend", TRUE); 95 hal_device_property_set_bool (d, "power_management.can_suspend", TRUE);
96 else 96 else
97 hal_device_property_set_bool (d, "power_management.can_suspend", FALSE); 97 hal_device_property_set_bool (d, "power_management.can_suspend", FALSE);
98 98
99 hal_device_property_set_bool (d, "power_management.can_hibernate", FALSE); 99 hal_device_property_set_bool (d, "power_management.can_hibernate", FALSE);
100 } 100 }
101 101
102 if (drvctl_find_device ("acpibat0", NULL) == TRUE) 102 if (drvctl_find_device ("acpibat0", NULL) == TRUE)
103 hal_device_property_set_string (d, "system.formfactor", "laptop"); 103 hal_device_property_set_string (d, "system.formfactor", "laptop");
104 else 104 else
105 hal_device_property_set_string (d, "system.formfactor", "desktop"); /* XXX */ 105 hal_device_property_set_string (d, "system.formfactor", "desktop"); /* XXX */
106 106
107 devinfo_add_enqueue (d, devnode, &devinfo_default_handler); 107 devinfo_add_enqueue (d, devnode, &devinfo_default_handler);
108 108
109 return d; 109 return d;
110} 110}
111 111
112static HalDevice * 112static HalDevice *
113devinfo_cpu_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) 113devinfo_cpu_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type)
114{ 114{
115 HalDevice *d; 115 HalDevice *d;
116 116
117 if (strncmp(devnode, "cpu", 3) != 0) { 117 if (strncmp(devnode, "cpu", 3) != 0) {
118 return (NULL); 118 return (NULL);
119 } 119 }
120 120
121 HAL_INFO (("devinfo_cpu_add: parent=%p devnode=%s devfs_path=%s device_type=%s", 121 HAL_INFO (("devinfo_cpu_add: parent=%p devnode=%s devfs_path=%s device_type=%s",
122 parent, devnode, devfs_path, device_type)); 122 parent, devnode, devfs_path, device_type));
123 123
124 d = hal_device_new (); 124 d = hal_device_new ();
125 125
126 devinfo_set_default_properties (d, parent, devnode, devnode); 126 devinfo_set_default_properties (d, parent, devnode, devnode);
127 hal_device_add_capability (d, "processor"); 127 hal_device_add_capability (d, "processor");
128 128
129 devinfo_add_enqueue (d, devnode, &devinfo_cpu_handler); 129 devinfo_add_enqueue (d, devnode, &devinfo_cpu_handler);
130 130
131 return (d); 131 return (d);
132} 132}
133 133
134static void 134static void
135devinfo_default_apply_quirks(HalDevice *d, const char *devnode) 135devinfo_default_apply_quirks(HalDevice *d, const char *devnode)
136{ 136{
137 137
138/* acpiacad(4) */ 138/* acpiacad(4) */
139 if (strncmp (devnode, "acpiacad", 8) == 0) { 139 if (strncmp (devnode, "acpiacad", 8) == 0) {
140 HAL_INFO (("%s: applying acpiacad quirks",devnode)); 140 HAL_INFO (("%s: applying acpiacad quirks",devnode));
141 hal_device_add_capability (d, "ac_adapter"); 141 hal_device_add_capability (d, "ac_adapter");
142 142
143/* acpibat(4) */ 143/* acpibat(4) */
144 } else if (strncmp (devnode, "acpibat", 7) == 0) { 144 } else if (strncmp (devnode, "acpibat", 7) == 0) {
145 HAL_INFO (("%s: applying acpibat quirks",devnode)); 145 HAL_INFO (("%s: applying acpibat quirks",devnode));
146 hal_device_add_capability (d, "battery"); 146 hal_device_add_capability (d, "battery");
147 hal_device_property_set_string (d, "battery.type", "primary"); 147 hal_device_property_set_string (d, "battery.type", "primary");
148 } 148 }
149 149
150} 150}
151 151
152static HalDevice * 152static HalDevice *
153devinfo_default_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) 153devinfo_default_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type)
154{ 154{
155 char *driver_name; 155 char *driver_name;
156 const char *parent_path; 156 const char *parent_path;
157 HalDevice *d; 157 HalDevice *d;
158 158
159 d = hal_device_new (); 159 d = hal_device_new ();
160 160
161 devinfo_set_default_properties (d, parent, devnode, devnode); 161 devinfo_set_default_properties (d, parent, devnode, devnode);
162 162
163 devinfo_default_apply_quirks (d, devnode); 163 devinfo_default_apply_quirks (d, devnode);
164 164
165 devinfo_add_enqueue (d, devnode, &devinfo_default_handler); 165 devinfo_add_enqueue (d, devnode, &devinfo_default_handler);
166 166
167 return (d); 167 return (d);
168} 168}

cvs diff -r1.4 -r1.5 pkgsrc/sysutils/hal/files/hald-netbsd/drvctl.c (switch to unified diff)

--- pkgsrc/sysutils/hal/files/hald-netbsd/drvctl.c 2015/01/25 18:46:09 1.4
+++ pkgsrc/sysutils/hal/files/hald-netbsd/drvctl.c 2018/05/19 13:25:36 1.5
@@ -1,303 +1,311 @@ @@ -1,303 +1,311 @@
1/*************************************************************************** 1/***************************************************************************
2 * 2 *
3 * drvctl.c : NetBSD drvctl events 3 * drvctl.c : NetBSD drvctl events
4 * 4 *
5 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 5 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
6 * Use is subject to license terms. 6 * Use is subject to license terms.
7 * 7 *
8 * Licensed under the Academic Free License version 2.1 8 * Licensed under the Academic Free License version 2.1
9 * 9 *
10 **************************************************************************/ 10 **************************************************************************/
11 11
12#ifdef HAVE_CONFIG_H 12#ifdef HAVE_CONFIG_H
13# include <config.h> 13# include <config.h>
14#endif 14#endif
15 15
16#include <stdio.h> 16#include <stdio.h>
17#include <unistd.h> 17#include <unistd.h>
18#include <stdlib.h> 18#include <stdlib.h>
19#include <string.h> 19#include <string.h>
20#include <errno.h> 20#include <errno.h>
21#include <fcntl.h> 21#include <fcntl.h>
22#include <sys/ioctl.h> 22#include <sys/ioctl.h>
23#include <sys/drvctlio.h> 23#include <sys/drvctlio.h>
24#include <sys/dkio.h> 24#include <sys/dkio.h>
25#include <sys/stat.h> 25#include <sys/stat.h>
26#include <sys/drvctlio.h> 26#include <sys/drvctlio.h>
27#include <glib.h> 27#include <glib.h>
28 28
29#include "../osspec.h" 29#include "../osspec.h"
30#include "../logger.h" 30#include "../logger.h"
31#include "../hald.h" 31#include "../hald.h"
32#include "../hald_dbus.h" 32#include "../hald_dbus.h"
33#include "../device_info.h" 33#include "../device_info.h"
34#include "../util.h" 34#include "../util.h"
35#include "osspec_netbsd.h" 35#include "osspec_netbsd.h"
36#include "hotplug.h" 36#include "hotplug.h"
37#include "devinfo.h" 37#include "devinfo.h"
38#include "devinfo_storage.h" 38#include "devinfo_storage.h"
39#include "drvctl.h" 39#include "drvctl.h"
40 40
41static gboolean drvctl_iochannel_data(GIOChannel *, GIOCondition, gpointer); 41static gboolean drvctl_iochannel_data(GIOChannel *, GIOCondition, gpointer);
42static void drvctl_dev_add(gchar *); 42static void drvctl_dev_add(gchar *);
43static void drvctl_dev_remove(gchar *); 43static void drvctl_dev_remove(gchar *);
44static void drvctl_dev_branch(gchar *); 44static void drvctl_dev_branch(gchar *);
45 45
46static int drvctl_fd; 46static int drvctl_fd;
47static GIOChannel *drvctl_iochannel; 47static GIOChannel *drvctl_iochannel;
48 48
49gboolean 49gboolean
50drvctl_init(void) 50drvctl_init(void)
51{ 51{
52 drvctl_fd = open (DRVCTLDEV, O_RDWR); 52 drvctl_fd = open (DRVCTLDEV, O_RDWR);
53 if (drvctl_fd == -1) { 53 if (drvctl_fd == -1) {
54 HAL_INFO (("open(%s, O_RDWR) failed: %s", DRVCTLDEV, strerror(errno))); 54 HAL_INFO (("open(%s, O_RDWR) failed: %s", DRVCTLDEV, strerror(errno)));
55 return FALSE; 55 return FALSE;
56 } 56 }
57 57
58 drvctl_iochannel = g_io_channel_unix_new (drvctl_fd); 58 drvctl_iochannel = g_io_channel_unix_new (drvctl_fd);
59 if (drvctl_iochannel == NULL) { 59 if (drvctl_iochannel == NULL) {
60 HAL_INFO (("g_io_channel_unix_new failed")); 60 HAL_INFO (("g_io_channel_unix_new failed"));
61 return FALSE; 61 return FALSE;
62 } 62 }
63 g_io_add_watch (drvctl_iochannel, G_IO_IN, drvctl_iochannel_data, NULL); 63 g_io_add_watch (drvctl_iochannel, G_IO_IN, drvctl_iochannel_data, NULL);
64 64
65 return TRUE; 65 return TRUE;
66} 66}
67 67
68void 68void
69drvctl_fini(void) 69drvctl_fini(void)
70{ 70{
71 HAL_INFO (("drvctl_fini")); 71 HAL_INFO (("drvctl_fini"));
72} 72}
73 73
74static gboolean 74static gboolean
75drvctl_iochannel_data (GIOChannel *source, 75drvctl_iochannel_data (GIOChannel *source,
76 GIOCondition condition, 76 GIOCondition condition,
77 gpointer user_data) 77 gpointer user_data)
78{ 78{
79 prop_dictionary_t ev; 79 prop_dictionary_t ev;
80 const char *event, *device; 80 const char *event, *device;
81 int res; 81 int res;
82 82
83 HAL_INFO (("drvctl_iochannel_data")); 83 HAL_INFO (("drvctl_iochannel_data"));
84 84
85 res = prop_dictionary_recv_ioctl (drvctl_fd, DRVGETEVENT, &ev); 85 res = prop_dictionary_recv_ioctl (drvctl_fd, DRVGETEVENT, &ev);
86 if (res) { 86 if (res) {
87 HAL_WARNING (("DRVGETEVENT failed: %s", strerror(errno))); 87 HAL_WARNING (("DRVGETEVENT failed: %s", strerror(errno)));
88 return FALSE; 88 return FALSE;
89 } 89 }
90 90
91 if (!prop_dictionary_get_cstring_nocopy (ev, "event", &event)) { 91 if (!prop_dictionary_get_cstring_nocopy (ev, "event", &event)) {
92 HAL_WARNING (("DRVGETEVENT missing \"event\" parameter")); 92 HAL_WARNING (("DRVGETEVENT missing \"event\" parameter"));
93 goto done; 93 goto done;
94 } 94 }
95 if (!prop_dictionary_get_cstring_nocopy (ev, "device", &device)) { 95 if (!prop_dictionary_get_cstring_nocopy (ev, "device", &device)) {
96 HAL_WARNING (("DRVGETEVENT missing \"device\" parameter")); 96 HAL_WARNING (("DRVGETEVENT missing \"device\" parameter"));
97 goto done; 97 goto done;
98 } 98 }
99 99
100 HAL_INFO (("DRVGETEVENT event=%s device=%s", event, device)); 100 HAL_INFO (("DRVGETEVENT event=%s device=%s", event, device));
101 101
102 if (strcmp (event, "device-attach") == 0) { 102 if (strcmp (event, "device-attach") == 0) {
103 drvctl_dev_add (device); 103 drvctl_dev_add (device);
104 } else { 104 } else {
105 drvctl_dev_remove (device); 105 drvctl_dev_remove (device);
106 } 106 }
107 107
108done: 108done:
109 prop_object_release(ev); 109 prop_object_release(ev);
110 return TRUE; 110 return TRUE;
111} 111}
112 112
113static void 113static void
114drvctl_dev_add(gchar *name) 114drvctl_dev_add(gchar *name)
115{ 115{
116 HalDevice *parent, *d; 116 HalDevice *parent, *d;
117 gchar pdevnode[512]; 117 gchar pdevnode[512];
118 118
119 if (drvctl_find_parent (name, pdevnode) == FALSE) { 119 if (drvctl_find_parent (name, pdevnode) == FALSE) {
120 HAL_INFO (("dev_add: name=%s orphan", name)); 120 HAL_INFO (("dev_add: name=%s orphan", name));
121 parent = NULL; 121 parent = NULL;
122 } else { 122 } else {
123 parent = hal_device_store_match_key_value_string ( 123 parent = hal_device_store_match_key_value_string (
124 hald_get_gdl(), "netbsd.device", pdevnode); 124 hald_get_gdl(), "netbsd.device", pdevnode);
125 if (parent == NULL) 125 if (parent == NULL)
126 HAL_INFO (("dev_add: name=%s but netbsd.device=%s not found",name, pdevnode)); 126 HAL_INFO (("dev_add: name=%s but netbsd.device=%s not found",name, pdevnode));
127 } 127 }
128 128
129 d = devinfo_add_node (parent, name); 129 d = devinfo_add_node (parent, name);
130 if (d == NULL) 130 if (d == NULL)
131 HAL_WARNING (("dev_add: couldn't add %s node (parent=%p)", name, parent)); 131 HAL_WARNING (("dev_add: couldn't add %s node (parent=%p)", name, parent));
132 132
133 hotplug_event_process_queue (); 133 hotplug_event_process_queue ();
134} 134}
135 135
136static void 136static void
137drvctl_dev_remove(gchar *name) 137drvctl_dev_remove(gchar *name)
138{ 138{
139 HAL_INFO (("dev_remove: %s", name)); 139 HAL_INFO (("dev_remove: %s", name));
140 140
141 devinfo_remove_branch (name, NULL); 141 devinfo_remove_branch (name, NULL);
142 hotplug_event_process_queue (); 142 hotplug_event_process_queue ();
143} 143}
144 144
145static void 145static void
146drvctl_dev_branch(gchar *name) 146drvctl_dev_branch(gchar *name)
147{ 147{
148 HAL_INFO (("branch_remove: %s", name)); 148 HAL_INFO (("branch_remove: %s", name));
149 149
150 devinfo_remove_branch (name, NULL); 150 devinfo_remove_branch (name, NULL);
151 hotplug_event_process_queue (); 151 hotplug_event_process_queue ();
152} 152}
153 153
154int 154int
155drvctl_list(const gchar *name, struct devlistargs *laa) 155drvctl_list(const gchar *name, struct devlistargs *laa)
156{ 156{
157 size_t children; 157 size_t children;
158 158
159 /* HAL_INFO (("drvctl_list: %s", name)); */ 159 /* HAL_INFO (("drvctl_list: %s", name)); */
160 160
161 memset (laa, 0, sizeof (*laa)); 161 memset (laa, 0, sizeof (*laa));
162 strlcpy (laa->l_devname, name, sizeof (laa->l_devname)); 162 strlcpy (laa->l_devname, name, sizeof (laa->l_devname));
163 if (ioctl (drvctl_fd, DRVLISTDEV, laa) == -1) { 163 if (ioctl (drvctl_fd, DRVLISTDEV, laa) == -1) {
164 HAL_INFO (("DRVLISTDEV/1 failed: %s", strerror(errno))); 164 HAL_INFO (("DRVLISTDEV/1 failed: %s", strerror(errno)));
165 return -1; 165 return -1;
166 } 166 }
167 children = laa->l_children; 167 children = laa->l_children;
168 /* HAL_INFO (("%s: found %d children", name, children)); */ 168 /* HAL_INFO (("%s: found %d children", name, children)); */
169 if (children == 0) 169 if (children == 0)
170 return -1; 170 return -1;
171 laa->l_childname = malloc (children * sizeof (laa->l_childname[0])); 171 laa->l_childname = malloc (children * sizeof (laa->l_childname[0]));
172 if (laa->l_childname == NULL) { 172 if (laa->l_childname == NULL) {
173 HAL_INFO (("drvctl_list couldn't allocate %d children: %s\n", children, strerror(errno))); 173 HAL_INFO (("drvctl_list couldn't allocate %d children: %s\n", children, strerror(errno)));
174 return -1; 174 return -1;
175 } 175 }
176 if (ioctl (drvctl_fd, DRVLISTDEV, laa) == -1) { 176 if (ioctl (drvctl_fd, DRVLISTDEV, laa) == -1) {
177 HAL_INFO (("DRVLISTDEV/2 failed: %s", strerror(errno))); 177 HAL_INFO (("DRVLISTDEV/2 failed: %s", strerror(errno)));
178 return -1; 178 return -1;
179 } 179 }
180 if (children != laa->l_children) 180 if (children != laa->l_children)
181 HAL_WARNING (("DRVLISTDEV/3 expected %d children, got %d", children, laa->l_childname)); 181 HAL_WARNING (("DRVLISTDEV/3 expected %d children, got %d", children, laa->l_childname));
 182 return 0;
182} 183}
183 184
184gboolean 185gboolean
185drvctl_find_device(const gchar *devnode, prop_dictionary_t *properties) 186drvctl_find_device(const gchar *devnode, prop_dictionary_t *properties)
186{ 187{
187 prop_dictionary_t command_dict; 188 prop_dictionary_t command_dict;
188 prop_dictionary_t args_dict; 189 prop_dictionary_t args_dict;
189 prop_dictionary_t results_dict; 190 prop_dictionary_t results_dict;
190 int err; 191 int err;
191  192
192 command_dict = prop_dictionary_create (); 193 command_dict = prop_dictionary_create ();
193 args_dict = prop_dictionary_create (); 194 args_dict = prop_dictionary_create ();
194  195
195 prop_dictionary_set_cstring_nocopy (command_dict, "drvctl-command", "get-properties"); 196 prop_dictionary_set_cstring_nocopy (command_dict, "drvctl-command", "get-properties");
196 prop_dictionary_set_cstring_nocopy (args_dict, "device-name", devnode);  197 prop_dictionary_set_cstring_nocopy (args_dict, "device-name", devnode);
197 prop_dictionary_set (command_dict, "drvctl-arguments", args_dict); 198 prop_dictionary_set (command_dict, "drvctl-arguments", args_dict);
198 prop_object_release (args_dict); 199 prop_object_release (args_dict);
199 200
200 err = prop_dictionary_sendrecv_ioctl (command_dict, drvctl_fd, 201 err = prop_dictionary_sendrecv_ioctl (command_dict, drvctl_fd,
201 DRVCTLCOMMAND, &results_dict); 202 DRVCTLCOMMAND, &results_dict);
202 prop_object_release (command_dict); 203 prop_object_release (command_dict);
203 if (err) 204 if (err)
204 return FALSE; 205 return FALSE;
205 206
206 if (prop_dictionary_get_int8 (results_dict, "drvctl-error", &err) == false || err != 0) { 207 if (prop_dictionary_get_int8 (results_dict, "drvctl-error", &err) == false || err != 0) {
207 prop_object_release (results_dict); 208 prop_object_release (results_dict);
208 return FALSE; 209 return FALSE;
209 } 210 }
210 211
211 if (properties) { 212 if (properties) {
212 prop_dictionary_t result_data; 213 prop_dictionary_t result_data;
213 result_data = prop_dictionary_get (results_dict, "drvctl-result-data"); 214 result_data = prop_dictionary_get (results_dict, "drvctl-result-data");
214 if (result_data) 215 if (result_data)
215 *properties = prop_dictionary_copy (result_data); 216 *properties = prop_dictionary_copy (result_data);
216 } 217 }
217 218
218 prop_object_release (results_dict); 219 prop_object_release (results_dict);
219 220
220 return TRUE; 221 return TRUE;
221} 222}
222 223
223static gboolean 224static gboolean
224drvctl_find_device_with_child(const gchar *curnode, const gchar *devnode, 225drvctl_find_device_with_child(const gchar *curnode, const gchar *devnode,
225 char *parent) 226 char *parent)
226{ 227{
227 struct devlistargs laa; 228 struct devlistargs laa;
228 u_int i; 229 u_int i;
229 230
230 if (drvctl_list (curnode, &laa) == -1) 231 if (drvctl_list (curnode, &laa) == -1)
231 return FALSE; 232 return FALSE;
232 233
233 for (i = 0; i < laa.l_children; i++) { 234 for (i = 0; i < laa.l_children; i++) {
234 if (strcmp (laa.l_childname[i], devnode) == 0) { 235 if (strcmp (laa.l_childname[i], devnode) == 0) {
235 strlcpy(parent, curnode, 16); 236 strlcpy(parent, curnode, 16);
236 free(laa.l_childname); 237 free(laa.l_childname);
237 return TRUE; 238 return TRUE;
238 } 239 }
239 if (drvctl_find_device_with_child (laa.l_childname[i], devnode, parent) == TRUE) { 240 if (drvctl_find_device_with_child (laa.l_childname[i], devnode, parent) == TRUE) {
240 free(laa.l_childname); 241 free(laa.l_childname);
241 return TRUE; 242 return TRUE;
242 } 243 }
243 } 244 }
244 245
245 if (laa.l_childname) 246 if (laa.l_childname)
246 free(laa.l_childname); 247 free(laa.l_childname);
247 248
248 HAL_INFO (("%s: couldn't find device with child %s", curnode, devnode)); 249 HAL_INFO (("%s: couldn't find device with child %s", curnode, devnode));
249 return FALSE; 250 return FALSE;
250} 251}
251 252
252gboolean 253gboolean
253drvctl_find_parent(const gchar *devnode, char *parent) 254drvctl_find_parent(const gchar *devnode, char *parent)
254{ 255{
255 return drvctl_find_device_with_child("mainbus0", devnode, parent); 256 gboolean ret;
 257
 258 ret = drvctl_find_device_with_child("mainbus0", devnode, parent);
 259 if (ret == FALSE) {
 260 ret = drvctl_find_device_with_child("armfdt0", devnode, parent);
 261 }
 262
 263 return ret;
256} 264}
257 265
258#if 0 266#if 0
259static void 267static void
260drvctl_lofi_add(gchar *devfs_path, gchar *name) 268drvctl_lofi_add(gchar *devfs_path, gchar *name)
261{ 269{
262 di_node_t node; 270 di_node_t node;
263 const char *parent_udi; 271 const char *parent_udi;
264 HalDevice *d, *parent; 272 HalDevice *d, *parent;
265 273
266 HAL_INFO (("lofi_add: %s %s", name, devfs_path)); 274 HAL_INFO (("lofi_add: %s %s", name, devfs_path));
267 275
268 if ((d = hal_device_store_match_key_value_string (hald_get_gdl (), 276 if ((d = hal_device_store_match_key_value_string (hald_get_gdl (),
269 "solaris.devfs_path", devfs_path)) == NULL) { 277 "solaris.devfs_path", devfs_path)) == NULL) {
270 HAL_INFO (("device not found in GDL %s", devfs_path)); 278 HAL_INFO (("device not found in GDL %s", devfs_path));
271 return; 279 return;
272 } 280 }
273 parent_udi = hal_device_property_get_string (d, "info.parent"); 281 parent_udi = hal_device_property_get_string (d, "info.parent");
274 if ((parent_udi == NULL) || (strlen(parent_udi) == 0)) { 282 if ((parent_udi == NULL) || (strlen(parent_udi) == 0)) {
275 HAL_INFO (("parent not found in GDL %s", parent_udi)); 283 HAL_INFO (("parent not found in GDL %s", parent_udi));
276 return; 284 return;
277 } 285 }
278 if ((parent = hal_device_store_match_key_value_string (hald_get_gdl (), 286 if ((parent = hal_device_store_match_key_value_string (hald_get_gdl (),
279 "info.udi", parent_udi)) == NULL) { 287 "info.udi", parent_udi)) == NULL) {
280 HAL_INFO (("parent not found in GDL %s", parent_udi)); 288 HAL_INFO (("parent not found in GDL %s", parent_udi));
281 return; 289 return;
282 } 290 }
283 291
284 if ((node = di_init (devfs_path, DINFOCPYALL)) == DI_NODE_NIL) { 292 if ((node = di_init (devfs_path, DINFOCPYALL)) == DI_NODE_NIL) {
285 HAL_INFO (("device not found in devinfo %s", devfs_path)); 293 HAL_INFO (("device not found in devinfo %s", devfs_path));
286 return; 294 return;
287 } 295 }
288 296
289 HAL_INFO (("device %s parent %s", hal_device_get_udi (d), parent_udi)); 297 HAL_INFO (("device %s parent %s", hal_device_get_udi (d), parent_udi));
290 devinfo_lofi_add_major (parent, node, devfs_path, NULL, TRUE, d); 298 devinfo_lofi_add_major (parent, node, devfs_path, NULL, TRUE, d);
291 299
292 di_fini (node); 300 di_fini (node);
293 301
294 hotplug_event_process_queue (); 302 hotplug_event_process_queue ();
295} 303}
296 304
297static void 305static void
298drvctl_lofi_remove(gchar *parent_devfs_path, gchar *name) 306drvctl_lofi_remove(gchar *parent_devfs_path, gchar *name)
299{ 307{
300 devinfo_lofi_remove_minor(parent_devfs_path, name); 308 devinfo_lofi_remove_minor(parent_devfs_path, name);
301 hotplug_event_process_queue (); 309 hotplug_event_process_queue ();
302} 310}
303#endif 311#endif

cvs diff -r1.3 -r1.4 pkgsrc/sysutils/hal/files/hald-netbsd/osspec.c (switch to unified diff)

--- pkgsrc/sysutils/hal/files/hald-netbsd/osspec.c 2008/12/01 02:02:33 1.3
+++ pkgsrc/sysutils/hal/files/hald-netbsd/osspec.c 2018/05/19 13:25:36 1.4
@@ -1,183 +1,188 @@ @@ -1,183 +1,188 @@
1/*************************************************************************** 1/***************************************************************************
2 * 2 *
3 * osspec.c : NetBSD HAL backend entry points 3 * osspec.c : NetBSD HAL backend entry points
4 * 4 *
5 * Copyright 2008 Jared D. McNeill <jmcneill@NetBSD.org> 5 * Copyright 2008 Jared D. McNeill <jmcneill@NetBSD.org>
6 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 6 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms. 7 * Use is subject to license terms.
8 * 8 *
9 * Licensed under the Academic Free License version 2.1 9 * Licensed under the Academic Free License version 2.1
10 * 10 *
11 **************************************************************************/ 11 **************************************************************************/
12 12
13#ifdef HAVE_CONFIG_H 13#ifdef HAVE_CONFIG_H
14# include <config.h> 14# include <config.h>
15#endif 15#endif
16 16
17#include <stdio.h> 17#include <stdio.h>
18#include <unistd.h> 18#include <unistd.h>
19#include <strings.h> 19#include <strings.h>
20#include <sys/stat.h> 20#include <sys/stat.h>
21#include <fcntl.h> 21#include <fcntl.h>
22#include <sys/types.h> 22#include <sys/types.h>
23#include <sys/statvfs.h> 23#include <sys/statvfs.h>
24 24
25#include "../osspec.h" 25#include "../osspec.h"
26#include "../logger.h" 26#include "../logger.h"
27#include "../hald.h" 27#include "../hald.h"
28#include "../hald_dbus.h" 28#include "../hald_dbus.h"
29#include "../device_info.h" 29#include "../device_info.h"
30#include "../util.h" 30#include "../util.h"
31#include "../ids.h" 31#include "../ids.h"
32#include "osspec_netbsd.h" 32#include "osspec_netbsd.h"
33#include "hotplug.h" 33#include "hotplug.h"
34#include "drvctl.h" 34#include "drvctl.h"
35#include "envsys.h" 35#include "envsys.h"
36#include "devinfo.h" 36#include "devinfo.h"
37#include "devinfo_storage.h" 37#include "devinfo_storage.h"
38 38
39static void mntinfo_event_init (); 39static void mntinfo_event_init ();
40static gboolean mntinfo_timeout (gpointer user_data); 40static gboolean mntinfo_timeout (gpointer user_data);
41 41
42HalFileMonitor * 42HalFileMonitor *
43osspec_get_file_monitor (void) 43osspec_get_file_monitor (void)
44{ 44{
45#warning Please implement 45#warning Please implement
46 return NULL; 46 return NULL;
47} 47}
48 48
49void 49void
50osspec_init (void) 50osspec_init (void)
51{ 51{
52 ids_init (); 52 ids_init ();
53 mntinfo_event_init (); 53 mntinfo_event_init ();
54 envsys_init (); 54 envsys_init ();
55} 55}
56 56
57void 57void
58osspec_privileged_init (void) 58osspec_privileged_init (void)
59{ 59{
60 drvctl_init (); 60 drvctl_init ();
61} 61}
62 62
63void 63void
64hotplug_queue_now_empty (void) 64hotplug_queue_now_empty (void)
65{ 65{
66 if (hald_is_initialising) { 66 if (hald_is_initialising) {
67 osspec_probe_done (); 67 osspec_probe_done ();
68 } 68 }
69} 69}
70 70
71void  71void
72osspec_probe (void) 72osspec_probe (void)
73{ 73{
74 /* add entire device tree */ 74 /* add entire device tree */
75 devinfo_add (NULL, "mainbus0"); 75 if (devinfo_probe (NULL, "mainbus0") == TRUE) {
 76 devinfo_add (NULL, "mainbus0");
 77 }
 78 if (devinfo_probe (NULL, "armfdt0") == TRUE) {
 79 devinfo_add (NULL, "armfdt0");
 80 }
76 81
77 /* start processing events */ 82 /* start processing events */
78 hotplug_event_process_queue (); 83 hotplug_event_process_queue ();
79} 84}
80 85
81gboolean 86gboolean
82osspec_device_rescan (HalDevice *d) 87osspec_device_rescan (HalDevice *d)
83{ 88{
84 return (devinfo_device_rescan (d)); 89 return (devinfo_device_rescan (d));
85} 90}
86 91
87gboolean 92gboolean
88osspec_device_reprobe (HalDevice *d) 93osspec_device_reprobe (HalDevice *d)
89{ 94{
90 return FALSE; 95 return FALSE;
91} 96}
92 97
93DBusHandlerResult 98DBusHandlerResult
94osspec_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data) 99osspec_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data)
95{ 100{
96 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 101 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
97} 102}
98 103
99/**  104/**
100 * hal_util_find_closest_ancestor: 105 * hal_util_find_closest_ancestor:
101 * @devfs_path: Path into devfs, e.g. /pci@0,0/pci1025,57@10,2/storage@1 106 * @devfs_path: Path into devfs, e.g. /pci@0,0/pci1025,57@10,2/storage@1
102 * 107 *
103 * Returns: Parent Hal Device Object or #NULL if there is none 108 * Returns: Parent Hal Device Object or #NULL if there is none
104 * 109 *
105 * Find the closest ancestor by looking at devfs paths 110 * Find the closest ancestor by looking at devfs paths
106 */ 111 */
107HalDevice * 112HalDevice *
108hal_util_find_closest_ancestor (const gchar *devfs_path, gchar **ancestor_devfs_path, gchar **hotplug_devfs_path) 113hal_util_find_closest_ancestor (const gchar *devfs_path, gchar **ancestor_devfs_path, gchar **hotplug_devfs_path)
109{ 114{
110 gchar buf[512]; 115 gchar buf[512];
111 gchar c; 116 gchar c;
112 HalDevice *parent; 117 HalDevice *parent;
113 118
114 parent = NULL; 119 parent = NULL;
115 120
116 if (drvctl_find_parent (devfs_path, buf) == FALSE) 121 if (drvctl_find_parent (devfs_path, buf) == FALSE)
117 return NULL; 122 return NULL;
118 123
119 HAL_INFO (("hal_util_find_closest_ancestor: devnode=%s parent=%s\n", devfs_path, buf)); 124 HAL_INFO (("hal_util_find_closest_ancestor: devnode=%s parent=%s\n", devfs_path, buf));
120 125
121 parent = hal_device_store_match_key_value_string (hald_get_gdl (), 126 parent = hal_device_store_match_key_value_string (hald_get_gdl (),
122 "netbsd.device", 127 "netbsd.device",
123 buf); 128 buf);
124 if (parent != NULL) { 129 if (parent != NULL) {
125 if (ancestor_devfs_path != NULL) { 130 if (ancestor_devfs_path != NULL) {
126 *ancestor_devfs_path = g_strdup (buf); 131 *ancestor_devfs_path = g_strdup (buf);
127 } 132 }
128 if (hotplug_devfs_path != NULL) { 133 if (hotplug_devfs_path != NULL) {
129 *hotplug_devfs_path = g_strdup (buf); 134 *hotplug_devfs_path = g_strdup (buf);
130 } 135 }
131 } 136 }
132 137
133 return parent; 138 return parent;
134} 139}
135 140
136char * 141char *
137dsk_to_rdsk(char *dsk) 142dsk_to_rdsk(char *dsk)
138{ 143{
139 int len, pos; 144 int len, pos;
140 char *p; 145 char *p;
141 char *rdsk; 146 char *rdsk;
142 147
143 if ((len = strlen (dsk)) < sizeof ("/dev/AANA") - 1) { 148 if ((len = strlen (dsk)) < sizeof ("/dev/AANA") - 1) {
144 return (strdup("")); 149 return (strdup(""));
145 } 150 }
146 p = strstr (dsk, "/dev/"); 151 p = strstr (dsk, "/dev/");
147 if (p == NULL) { 152 if (p == NULL) {
148 return (strdup("")); 153 return (strdup(""));
149 } 154 }
150 155
151 pos = (uintptr_t)p - (uintptr_t)dsk; 156 pos = (uintptr_t)p - (uintptr_t)dsk;
152 if ((rdsk = (char *)calloc (len + 2, 1)) != NULL) { 157 if ((rdsk = (char *)calloc (len + 2, 1)) != NULL) {
153 strncpy (rdsk, dsk, pos + 1); 158 strncpy (rdsk, dsk, pos + 1);
154 rdsk[pos + 1] = 'r'; 159 rdsk[pos + 1] = 'r';
155 strcpy (rdsk + pos + 2, dsk + pos + 1); 160 strcpy (rdsk + pos + 2, dsk + pos + 1);
156 } 161 }
157 162
158 return (rdsk); 163 return (rdsk);
159} 164}
160 165
161/* 166/*
162 * Setup to watch mntinfo changes 167 * Setup to watch mntinfo changes
163 */ 168 */
164static void 169static void
165mntinfo_event_init () 170mntinfo_event_init ()
166{ 171{
167 g_timeout_add (1000, mntinfo_timeout, NULL); 172 g_timeout_add (1000, mntinfo_timeout, NULL);
168} 173}
169 174
170static gboolean 175static gboolean
171mntinfo_timeout (gpointer user_data) 176mntinfo_timeout (gpointer user_data)
172{ 177{
173 if (!hald_is_initialising) 178 if (!hald_is_initialising)
174 vfsstat_event (NULL); 179 vfsstat_event (NULL);
175 180
176 return TRUE; 181 return TRUE;
177} 182}
178 183
179void 184void
180osspec_refresh_mount_state_for_block_device (HalDevice *d) 185osspec_refresh_mount_state_for_block_device (HalDevice *d)
181{ 186{
182 vfsstat_event (d); 187 vfsstat_event (d);
183} 188}